text
stringlengths 0
828
|
---|
default=None) |
parser.add_argument('--report-type', |
help='The output report type. By default metapipe will ' |
'print updates to the console. \nOptions: {}. ' |
'(Default: ""%(default)s)""'.format(QUEUE_TYPES.keys()), |
default='text') |
parser.add_argument('-v','--version', |
help='Displays the current version of the application.', |
action='store_true') |
args = parser.parse_args() |
if args.version: |
print('Version: {}'.format(__version__)) |
sys.exit(0) |
try: |
with open(args.input) as f: |
config = f.read() |
except IOError: |
print('No valid config file found.') |
return -1 |
run(config, args.max_jobs, args.output, args.job_type, args.report_type, |
args.shell, args.temp, args.run)" |
144,"def run(config, max_jobs, output=sys.stdout, job_type='local', |
report_type='text', shell='/bin/bash', temp='.metapipe', run_now=False): |
"""""" Create the metapipe based on the provided input. """""" |
if max_jobs == None: |
max_jobs = cpu_count() |
parser = Parser(config) |
try: |
command_templates = parser.consume() |
except ValueError as e: |
raise SyntaxError('Invalid config file. \n%s' % e) |
options = '\n'.join(parser.global_options) |
queue_type = QUEUE_TYPES[report_type] |
pipeline = Runtime(command_templates,queue_type,JOB_TYPES,job_type,max_jobs) |
template = env.get_template('output_script.tmpl.sh') |
with open(temp, 'wb') as f: |
pickle.dump(pipeline, f, 2) |
script = template.render(shell=shell, |
temp=os.path.abspath(temp), options=options) |
if run_now: |
output = output if output != sys.stdout else PIPELINE_ALIAS |
submit_job = make_submit_job(shell, output, job_type) |
submit_job.submit() |
try: |
f = open(output, 'w') |
output = f |
except TypeError: |
pass |
output.write(script) |
f.close()" |
145,"def make_submit_job(shell, output, job_type): |
"""""" Preps the metapipe main job to be submitted. """""" |
run_cmd = [shell, output] |
submit_command = Command(alias=PIPELINE_ALIAS, cmds=run_cmd) |
submit_job = get_job(submit_command, job_type) |
submit_job.make() |
return submit_job" |
146,"def yaml(modules_to_register: Iterable[Any] = None, classes_to_register: Iterable[Any] = None) -> ruamel.yaml.YAML: |
"""""" Create a YAML object for loading a YAML configuration. |
Args: |
modules_to_register: Modules containing classes to be registered with the YAML object. Default: None. |
classes_to_register: Classes to be registered with the YAML object. Default: None. |
Returns: |
A newly creating YAML object, configured as apporpirate. |
"""""" |
# Defein a round-trip yaml object for us to work with. This object should be imported by other modules |
# NOTE: ""typ"" is a not a typo. It stands for ""type"" |
yaml = ruamel.yaml.YAML(typ = ""rt"") |
# Register representers and constructors |
# Numpy |
yaml.representer.add_representer(np.ndarray, numpy_to_yaml) |
yaml.constructor.add_constructor(""!numpy_array"", numpy_from_yaml) |
# Register external classes |
yaml = register_module_classes(yaml = yaml, modules = modules_to_register) |
yaml = register_classes(yaml = yaml, classes = classes_to_register) |
return yaml" |
147,"def register_classes(yaml: ruamel.yaml.YAML, classes: Optional[Iterable[Any]] = None) -> ruamel.yaml.YAML: |
"""""" Register externally defined classes. """""" |
# Validation |
if classes is None: |
classes = [] |
# Register the classes |
for cls in classes: |
logger.debug(f""Registering class {cls} with YAML"") |
yaml.register_class(cls) |
return yaml" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.