-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use shlex.quote
to convert the arguments into unix format
#209
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,7 +2,6 @@ | |||
import getpass | ||||
import tarfile | ||||
import shlex | ||||
import json | ||||
import tempfile | ||||
import time | ||||
import threading | ||||
|
@@ -25,6 +24,7 @@ | |||
TransformationCatalog, | ||||
ReplicaCatalog, | ||||
) | ||||
from alea.runner import Runner | ||||
from alea.submitter import Submitter | ||||
from alea.utils import load_yaml, dump_yaml | ||||
|
||||
|
@@ -449,13 +449,14 @@ def _initialize_job( | |||
|
||||
""" | ||||
job = Job(name) | ||||
job.add_profiles(Namespace.CONDOR, "request_cpus", f"{cores}") | ||||
|
||||
if run_on_submit_node: | ||||
job.add_selector_profile(execution_site="local") | ||||
# no other attributes on a local job | ||||
return job | ||||
|
||||
job.add_profiles(Namespace.CONDOR, "request_cpus", f"{cores}") | ||||
|
||||
# Set memory and disk requirements | ||||
# If the job fails, retry with more memory and disk | ||||
# Somehow we need to write memory in MB and disk in kB | ||||
|
@@ -497,13 +498,7 @@ def _add_separate_job(self, combine_i): | |||
"""Add a separate job to the workflow.""" | ||||
logger.info(f"Adding separate job {combine_i} to the workflow") | ||||
separate_name = "separate" | ||||
separate_job = self._initialize_job( | ||||
name=separate_name, | ||||
cores=1, | ||||
memory=self.request_memory * 2, | ||||
disk=self.combine_disk, | ||||
run_on_submit_node=True, | ||||
) | ||||
separate_job = self._initialize_job(name=separate_name, run_on_submit_node=True) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For separation jobs, these arguments are not really used. |
||||
|
||||
# Separate job configuration: all toymc results and files will be combined into one tarball | ||||
separate_job.add_inputs(File(f"{self.workflow_id}-{combine_i}-combined_output.tar.gz")) | ||||
|
@@ -565,6 +560,9 @@ def _generate_workflow(self, name="run_toymc_wrapper"): | |||
combine_i = 0 | ||||
new_to_combine = True | ||||
|
||||
# Prepare for argument conversion | ||||
_, _, annotations = Runner.runner_arguments() | ||||
|
||||
# Generate jobstring and output names from tickets generator | ||||
for job_id, (script, _) in enumerate(self.combined_tickets_generator()): | ||||
# If the number of jobs to combine is reached, add a new combine job | ||||
|
@@ -638,10 +636,11 @@ def _generate_workflow(self, name="run_toymc_wrapper"): | |||
|
||||
# Add the arguments into the job | ||||
# Using escaped argument to avoid the shell syntax error | ||||
def _extract_all_to_tuple(d): | ||||
def _extract_all_to_tuple(kwargs) -> tuple: | ||||
"""Generate the submission script from the runner arguments.""" | ||||
return tuple( | ||||
f"{json.dumps(str(d[key])).replace(' ', '')}".replace("'", '\\"') | ||||
for key in d.keys() | ||||
shlex.quote(Submitter.arg_to_str(kwargs[arg], annotation)) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to Line 579 in 09f35f5
|
||||
for arg, annotation in annotations.items() | ||||
) | ||||
|
||||
# Correct the paths in the arguments | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ | |
|
||
set -e | ||
|
||
# Check if number of arguments passed is correct | ||
if [ $# -ne 21 ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the number of arguments. |
||
echo "Error: You need to provide required number of arguments." | ||
exit 1 | ||
fi | ||
|
||
# Extract the arguments | ||
statistical_model=$1 | ||
poi=$2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request_cpus
can not be assigned to a local job.