def test_yaml_template(): config_file = tempfile.mkstemp(suffix='test_yaml_template')[1] # Create a new YAML configuration file based on the default_pipeline.yml file. config = yaml.safe_load(open('./data/default_pipeline.yml', 'r')) new_config = create_yaml_from_template(config, './data/default_pipeline.yml') with open(config_file, 'wb') as f: f.write(new_config) # Verify that the output has preserved blank lines, comments with open(config_file, 'r') as f: lines = f.readlines() # Assert first lines starts with a comment assert lines[0].startswith('# ') # Assert that there are blank lines assert lines[6].isspace() assert lines[7].isspace() # Assert that regressors configuration written in block style assert lines[669].startswith('Regressors:') assert lines[670].startswith('- Bandpass:'******'roiTSOutputs: [true, true]')
def test_yaml_template(): config_file = tempfile.mkstemp(suffix='test_yaml_template')[1] with open("./default_pipeline.yaml", "r") as f: config = yaml.load(f) new_config = create_yaml_from_template(config, "./default_pipeline.yaml") with open(config_file, "wb") as f: f.write(new_config) # TODO test cases # Test lists, dicts and list of dicts # Look for who is in flow style and who is not # Check for default values # Check for comments
print("Available threads: {0}".format(c['maxCoresPerParticipant'])) print("Number of threads for ANTs: {0}".format(c['num_ants_threads'])) # create a timestamp for writing config files st = datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%SZ') # update config file if "s3://" not in args.output_dir.lower(): pipeline_config_file = os.path.join( args.output_dir, "cpac_pipeline_config_{0}.yml".format(st)) else: pipeline_config_file = os.path.join( "/scratch", "cpac_pipeline_config_{0}.yml".format(st)) with open(pipeline_config_file, 'w') as f: f.write(create_yaml_from_template(c, DEFAULT_PIPELINE)) participant_labels = [] if args.participant_label: participant_labels = [ 'sub-' + pt if not pt.startswith('sub-') else pt for pt in args.participant_label ] # otherwise we move on to conforming the data configuration if not args.data_config_file: from bids_utils import collect_bids_files_configs, bids_gen_cpac_sublist (file_paths, config) = collect_bids_files_configs(args.bids_dir,
print("Number of threads for ANTs: {0}".format( c['pipeline_setup']['system_config']['num_ants_threads'])) # create a timestamp for writing config files st = datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%SZ') # update config file if "s3://" not in args.output_dir.lower(): pipeline_config_file = os.path.join( args.output_dir, "cpac_pipeline_config_{0}.yml".format(st)) else: pipeline_config_file = os.path.join( DEFAULT_TMP_DIR, "cpac_pipeline_config_{0}.yml".format(st)) open(pipeline_config_file, 'w').write(create_yaml_from_template(c, DEFAULT_PIPELINE, True)) open(f'{pipeline_config_file[:-4]}_min.yml', 'w').write(create_yaml_from_template(c, DEFAULT_PIPELINE, False)) participant_labels = [] if args.participant_label: participant_labels = [ 'sub-' + pt if not pt.startswith('sub-') else pt for pt in args.participant_label ] # otherwise we move on to conforming the data configuration if not args.data_config_file: sub_list = create_cpac_data_config(args.bids_dir, args.participant_label, args.aws_input_creds,
print("Available threads: {0}".format(c['maxCoresPerParticipant'])) print("Number of threads for ANTs: {0}".format(c['num_ants_threads'])) # create a timestamp for writing config files ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S') # update config file if "s3://" not in args.output_dir.lower(): config_file = os.path.join(args.output_dir, "cpac_pipeline_config_{0}.yml".format(st)) else: config_file = os.path.join("/scratch", "cpac_pipeline_config_{0}.yml".format(st)) with open(config_file, 'w') as f: f.write(create_yaml_from_template(c, DEFAULT_PIPELINE)) # we have all we need if we are doing a group level analysis if args.analysis_level == "group": if not args.group_file or not os.path.exists(args.group_file): print() print() print("No group analysis configuration file was supplied.") print() import pkg_resources as p args.group_file = \ p.resource_filename("CPAC",