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
992ce1ba
Commit
992ce1ba
authored
Apr 08, 2020
by
Anton Pershin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил поддержку множественных исследовательских каталогов в Research. Также сделал рефакторинг
parent
c5ffd6e9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
research.py
comsdk/research.py
+14
-13
No files found.
comsdk/research.py
View file @
992ce1ba
...
...
@@ -80,21 +80,21 @@ class Research:
"""
def
__init__
(
self
,
name
,
continuing
=
False
,
local_research_path
=
None
,
local_research_path
s
=
None
,
remote_comm
=
None
,
remote_research_path
=
None
,
):
# Always create local communication here
# Remote communication is optional then
self
.
local_research_path
=
local_research_path
self
.
local_main_path
=
os
.
path
.
dirname
(
local_research_path
)
self
.
local_research_path
=
local_research_path
s
[
0
]
self
.
local_main_path
=
os
.
path
.
dirname
(
self
.
local_research_path
)
self
.
remote_research_path
=
remote_research_path
self
.
_tasks_number
=
0
self
.
_local_comm
=
LocalCommunication
(
Host
())
self
.
_remote_comm
=
remote_comm
# NOTE: at the moment we do not need features of the distributed storage
#self._distr_storage = DistributedStorage((rset.LOCAL_HOST['main_research_path'], rset.LOCAL_HOST['storage_research_path']), prior_storage_index=1)
self
.
_distr_storage
=
DistributedStorage
(
(
self
.
local_research_path
,)
,
prior_storage_index
=
0
)
self
.
_distr_storage
=
DistributedStorage
(
local_research_paths
,
prior_storage_index
=
0
)
suitable_name
=
self
.
_make_suitable_name
(
name
)
if
not
continuing
:
# interpret name as name without date
...
...
@@ -132,9 +132,9 @@ class Research:
conf
=
json
.
load
(
f
)
res
=
Research
(
conf
[
'RESEARCH'
][
research_sid
],
continuing
=
True
,
local_research_path
=
conf
[
'LOCAL_HOST'
][
'research_path'
],
local_research_path
s
=
conf
[
'LOCAL_HOST'
][
'research_paths'
],
remote_comm
=
remote_comm
,
remote_research_path
=
conf
[
'REMOTE_HOSTS'
][
remote_comm
.
machine_name
][
'research_path'
])
remote_research_path
=
conf
[
'REMOTE_HOSTS'
][
remote_comm
.
machine_name
][
'research_path'
]
if
remote_comm
is
not
None
else
None
)
res
.
_add_properties
(
conf
[
'RESEARCH_PROPS'
])
return
res
...
...
@@ -203,25 +203,26 @@ class Research:
dir located in the main research location.
'''
task_results_local_path
=
self
.
get_task_path
(
task_number
)
task_results_remote_path
=
self
.
get_task_path
(
task_number
,
self
.
_
exec
_comm
.
host
)
task_results_remote_path
=
self
.
get_task_path
(
task_number
,
self
.
_
remote
_comm
.
host
)
if
len
(
copies_list
)
==
0
:
# copy all data
pathes
=
self
.
_
exec
_comm
.
listdir
(
task_results_remote_path
)
pathes
=
self
.
_
remote
_comm
.
listdir
(
task_results_remote_path
)
for
file_or_dir
in
pathes
:
self
.
_
exec_comm
.
copy
(
'/'
.
join
((
task_results_remote_path
,
file_or_dir
)),
task_results_local_path
,
'from_remote'
)
self
.
_
remote_comm
.
copy
(
'/'
.
join
((
task_results_remote_path
,
file_or_dir
)),
task_results_local_path
,
'from_remote'
,
show_msg
=
True
)
else
:
for
copy_target
in
copies_list
:
remote_copy_target_path
=
'/'
.
join
((
task_results_remote_path
,
copy_target
[
'path'
]))
# we consider copy targets as relative to task's dir
self
.
_
exec_comm
.
copy
(
remote_copy_target_path
,
task_results_local_path
,
'from_remote'
)
self
.
_
remote_comm
.
copy
(
remote_copy_target_path
,
task_results_local_path
,
'from_remote'
,
show_msg
=
True
)
if
'new_name'
in
copy_target
:
os
.
rename
(
os
.
path
.
join
(
task_results_local_path
,
os
.
path
.
basename
(
copy_target
[
'path'
])),
\
os
.
path
.
join
(
task_results_local_path
,
copy_target
[
'new_name'
]))
def
_make_task_path
(
self
,
task_number
,
task_name
,
execution_host
=
None
):
task_path
=
''
rel_task_dir
=
os
.
path
.
join
(
self
.
_research_id
,
self
.
_get_task_full_name
(
task_number
,
task_name
)
)
task_dir
=
self
.
_get_task_full_name
(
task_number
,
task_name
)
if
execution_host
is
None
:
task_path
=
os
.
path
.
join
(
self
.
local_research_path
,
rel_
task_dir
)
task_path
=
os
.
path
.
join
(
self
.
research_path
,
task_dir
)
else
:
rel_task_dir
=
os
.
path
.
join
(
self
.
_research_id
,
task_dir
)
task_path
=
os
.
path
.
join
(
execution_host
.
research_abs_path
,
rel_task_dir
)
return
task_path
...
...
@@ -289,7 +290,7 @@ class ResearchDoesNotExist(Exception):
pass
def
get_all_research_ids
():
return
os
.
listdir
(
'.'
+
self
.
local_
research_path
)
return
os
.
listdir
(
'.'
+
self
.
research_path
)
def
retrieve_trailing_float_from_task_dir
(
task_dir
):
matching
=
re
.
search
(
'^(?P<task_number>
\
d+)-(?P<task_name>
\
S+)_(?P<float_left>
\
d+)
\
.(?P<float_right>
\
d+)'
,
task_dir
)
...
...
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