Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
4ba06c72
Commit
4ba06c72
authored
3 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Start working on ability to recreate environment for xfel_calibrate.repeat
parent
9c562dca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!660
Recreate environments on demand for xfel-calibrate-repeat
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xfel_calibrate/repeat.py
+22
-2
22 additions, 2 deletions
src/xfel_calibrate/repeat.py
with
22 additions
and
2 deletions
src/xfel_calibrate/repeat.py
+
22
−
2
View file @
4ba06c72
...
@@ -5,6 +5,7 @@ from datetime import datetime
...
@@ -5,6 +5,7 @@ from datetime import datetime
from
pathlib
import
Path
from
pathlib
import
Path
import
nbformat
import
nbformat
from
env_cache
import
EnvsManager
,
FixedPythonEnvMaker
from
nbparameterise
import
extract_parameters
,
parameter_values
,
replace_definitions
from
nbparameterise
import
extract_parameters
,
parameter_values
,
replace_definitions
from
cal_tools.tools
import
CalibrationMetadata
from
cal_tools.tools
import
CalibrationMetadata
...
@@ -31,10 +32,28 @@ def new_report_path(old_out_folder, old_report_path, new_out_folder):
...
@@ -31,10 +32,28 @@ def new_report_path(old_out_folder, old_report_path, new_out_folder):
else
:
else
:
return
str
(
Path
(
new_out_folder
,
report_in_output
))
return
str
(
Path
(
new_out_folder
,
report_in_output
))
def
get_python
(
args
,
py_version
):
if
args
.
env_from_python
:
reqs
=
(
args
.
from_dir
/
'
requirements.txt
'
).
read_text
()
env_mgr
=
EnvsManager
(
Path
(
temp_path
,
'
envs
'
),
FixedPythonEnvMaker
(
args
.
env_from_python
)
)
return
env_mgr
.
get_env
(
py_version
,
reqs
)
/
'
bin
'
/
'
python
'
elif
args
.
python
:
return
args
.
python
return
sys
.
executable
def
main
(
argv
=
None
):
def
main
(
argv
=
None
):
ap
=
argparse
.
ArgumentParser
()
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
"
from_dir
"
,
type
=
Path
,
help
=
"
A directory containing steps.json
"
)
ap
.
add_argument
(
"
from_dir
"
,
type
=
Path
,
help
=
"
A directory containing steps.json
"
)
ap
.
add_argument
(
"
--python
"
,
help
=
"
Path to Python executable to run notebooks
"
)
env_args
=
ap
.
add_mutually_exclusive_group
()
env_args
.
add_argument
(
"
--python
"
,
help
=
"
Path to Python executable to run notebooks
"
)
env_args
.
add_argument
(
"
--env-from-python
"
,
help
=
"
Make a virtualenv from this Python & install the library versions
"
"
these notebooks previously used
"
)
ap
.
add_argument
(
"
--out-folder
"
,
help
=
"
Directory to put output data
"
)
ap
.
add_argument
(
"
--out-folder
"
,
help
=
"
Directory to put output data
"
)
ap
.
add_argument
(
"
--slurm-partition
"
,
help
=
"
Submit jobs in this Slurm partition
"
)
ap
.
add_argument
(
"
--slurm-partition
"
,
help
=
"
Submit jobs in this Slurm partition
"
)
ap
.
add_argument
(
'
--no-cluster-job
'
,
action
=
"
store_true
"
,
ap
.
add_argument
(
'
--no-cluster-job
'
,
action
=
"
store_true
"
,
...
@@ -70,8 +89,9 @@ def main(argv=None):
...
@@ -70,8 +89,9 @@ def main(argv=None):
Path
(
out_folder
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
Path
(
out_folder
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
shutil
.
copy
(
working_dir
/
'
calibration_metadata.yml
'
,
out_folder
)
shutil
.
copy
(
working_dir
/
'
calibration_metadata.yml
'
,
out_folder
)
py_version
=
cal_metadata
.
get
(
'
python-environment
'
,
{}).
get
(
'
python-version
'
)
job_chain
=
JobChain
.
from_dir
(
job_chain
=
JobChain
.
from_dir
(
working_dir
,
python
=
(
args
.
python
or
sys
.
executable
)
working_dir
,
python
=
get_python
(
args
,
py_version
)
)
)
if
args
.
no_cluster_job
:
if
args
.
no_cluster_job
:
job_chain
.
run_direct
()
job_chain
.
run_direct
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment