Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pycomsdk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com
pycomsdk
Commits
55ad2207
Commit
55ad2207
authored
Jan 23, 2023
by
Anton Pershin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added personal task shift to enable multiuser task upload
parent
5e99fc3e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
15 deletions
+14
-15
research.py
comsdk/research.py
+12
-15
config_research.json.example
config_research.json.example
+2
-0
No files found.
comsdk/research.py
View file @
55ad2207
...
...
@@ -52,7 +52,8 @@ class Research:
continuing
=
False
,
local_research_roots
:
Optional
[
Sequence
[
str
]]
=
None
,
remote_comm
:
Optional
[
BaseCommunication
]
=
None
,
remote_research_root
:
Optional
[
str
]
=
None
):
remote_research_root
:
Optional
[
str
]
=
None
,
personal_task_shift
=
0
):
"""
:param name: research description (if continuing == False) or research directory (if continuing == True)
:param continuing: if False, the Research with be read from the root path. Otherwise, a new one will be created
...
...
@@ -63,7 +64,8 @@ class Research:
self
.
_local_research_root
=
local_research_roots
[
0
]
self
.
_local_root
=
os
.
path
.
dirname
(
self
.
_local_research_root
)
self
.
_remote_research_root
=
remote_research_root
self
.
_tasks_number
=
0
self
.
_personal_task_shift
=
personal_task_shift
self
.
_tasks_number
=
personal_task_shift
self
.
_local_comm
=
LocalCommunication
(
Host
())
# local communication created automatically, no need to pass it
self
.
_remote_comm
=
remote_comm
self
.
_distr_storage
=
DistributedStorage
(
local_research_roots
,
prior_storage_index
=
0
)
...
...
@@ -96,7 +98,8 @@ class Research:
local_research_roots
=
conf
[
'LOCAL_HOST'
][
'research_roots'
],
remote_comm
=
remote_comm
,
remote_research_root
=
conf
[
'REMOTE_HOSTS'
][
remote_comm
.
machine_name
][
'research_root'
]
if
remote_comm
is
not
None
else
None
)
if
remote_comm
is
not
None
else
None
,
personal_task_shift
=
conf
[
'PERSONAL_TASK_SHIFT'
])
res
.
_add_properties
(
conf
[
'RESEARCH_PROPS'
])
return
res
...
...
@@ -120,7 +123,8 @@ class Research:
local_research_roots
=
conf
[
'LOCAL_HOST'
][
'research_roots'
],
remote_comm
=
remote_comm
,
remote_research_root
=
conf
[
'REMOTE_HOSTS'
][
remote_comm
.
machine_name
][
'research_root'
]
if
remote_comm
is
not
None
else
None
)
if
remote_comm
is
not
None
else
None
,
personal_task_shift
=
conf
[
'PERSONAL_TASK_SHIFT'
])
res
.
_add_properties
(
conf
[
'RESEARCH_PROPS'
])
return
res
...
...
@@ -145,11 +149,13 @@ class Research:
'research_dir'
:
self
.
_research_dir
,
'local_research_path'
:
self
.
_local_research_root
,
'remote_research_path'
:
self
.
_remote_research_root
,
'personal_task_shift'
:
self
.
_personal_task_shift
,
'remote_comm'
:
self
.
_remote_comm
.
__getstate__
(),
}
def
__setstate__
(
self
,
state
):
self
.
_tasks_number
=
0
self
.
_personal_task_shift
=
state
[
'personal_task_shift'
]
self
.
_tasks_number
=
self
.
_personal_task_shift
self
.
_local_comm
=
LocalCommunication
(
Host
())
self
.
_local_research_root
=
state
[
'local_research_path'
]
self
.
_remote_research_root
=
state
[
'remote_research_path'
]
...
...
@@ -171,27 +177,18 @@ class Research:
research_path
=
self
.
_distr_storage
.
get_dir_path
(
self
.
_research_dir
)
if
research_path
is
None
:
raise
ResearchDoesNotExist
(
"Research '{}' does not exist"
.
format
(
self
.
_research_dir
))
# if research_path is None:
# # assume date was omitted in research id
# regexp_for_search = '^(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)_{}'.format(self._research_name)
# research_path, dir_params = self._distr_storage.find_dir_by_named_regexp('', regexp_for_search)
# if dir_params is None:
# raise ResearchDoesNotExist("Research '{}' does not exist".format(self._research_name))
# self._research_name = '{}-{}-{}_{}'.format(dir_params['year'], dir_params['month'], dir_params['day'],
# self._research_name)
print
(
'Loaded research at {}'
.
format
(
research_path
))
# determine maximum task number to set the number for the next possible task
dirnames
,
_
=
self
.
_distr_storage
.
listdir
(
self
.
_research_dir
)
self
.
_tasks_number
=
0
for
dir_
in
dirnames
:
if
dir_
!=
'report'
:
task_number
,
_
=
split_task_dir
(
dir_
)
if
task_number
>
self
.
_tasks_number
:
self
.
_tasks_number
=
task_number
self
.
_tasks_number
+=
1
print
(
'N
umber of tasks in the current research
: {}'
.
format
(
self
.
_tasks_number
))
print
(
'N
ext created task in the current research will hold the following number
: {}'
.
format
(
self
.
_tasks_number
))
return
research_path
def
create_task
(
self
,
name
:
str
)
->
int
:
...
...
config_research.json.example
View file @
55ad2207
...
...
@@ -38,6 +38,7 @@
"RESEARCH_PROPS": {
...
},
"PERSONAL_TASK_SHIFT": 0,
"TEMPLATES_PATH": "...",
"MEETINGS_PATH": "..."
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment