classCommand(BaseCommand):""" This command creates measurements and measurement_pairs arrow files for a completed pipeline run. """help=('Create `measurements.arrow` and `measurement_pairs.arrow` files for a'' completed pipeline run.')defadd_arguments(self,parser:ArgumentParser)->None:""" Enables arguments for the command. Args: parser (ArgumentParser): The parser object of the command. Returns: None """# positional argumentsparser.add_argument('piperun',type=str,help='Path or name of the pipeline run.')parser.add_argument('--overwrite',action='store_true',required=False,default=False,help="Overwrite previous 'measurements.arrow' file.",)defhandle(self,*args,**options)->None:""" Handle function of the command. Args: *args: Variable length argument list. **options: Variable length options. Returns: None """# configure loggingifoptions['verbosity']>1:# set root logger to use the DEBUG levelroot_logger=logging.getLogger('')root_logger.setLevel(logging.DEBUG)# set the traceback onoptions['traceback']=Truepiperun=options['piperun']p_run_name,run_folder=get_p_run_name(piperun,return_folder=True)try:p_run=Run.objects.get(name=p_run_name)exceptRun.DoesNotExist:raiseCommandError(f'Pipeline run {p_run_name} does not exist')ifp_run.status!='END':raiseCommandError(f'Pipeline run {p_run_name} has not completed.')measurements_arrow=os.path.join(run_folder,'measurements.arrow')measurement_pairs_arrow=os.path.join(run_folder,'measurement_pairs.arrow')ifos.path.isfile(measurements_arrow):ifoptions['overwrite']:logger.info("Removing previous 'measurements.arrow' file.")os.remove(measurements_arrow)else:raiseCommandError(f'Measurements arrow file already exists for {p_run_name}'' and `--overwrite` has not been selected.')ifos.path.isfile(measurement_pairs_arrow):ifoptions['overwrite']:logger.info("Removing previous 'measurement_pairs.arrow' file.")os.remove(measurement_pairs_arrow)else:raiseCommandError('Measurement pairs arrow file already exists for'f' {p_run_name} and `--overwrite` has not been selected.')logger.info("Creating measurements arrow file for '%s'.",p_run_name)create_measurements_arrow_file(p_run)logger.info("Creating measurement pairs arrow file for '%s'.",p_run_name)create_measurement_pairs_arrow_file(p_run)
Source code in vast_pipeline/management/commands/createmeasarrow.py
343536373839404142434445464748495051525354555657
defadd_arguments(self,parser:ArgumentParser)->None:""" Enables arguments for the command. Args: parser (ArgumentParser): The parser object of the command. Returns: None """# positional argumentsparser.add_argument('piperun',type=str,help='Path or name of the pipeline run.')parser.add_argument('--overwrite',action='store_true',required=False,default=False,help="Overwrite previous 'measurements.arrow' file.",)
defhandle(self,*args,**options)->None:""" Handle function of the command. Args: *args: Variable length argument list. **options: Variable length options. Returns: None """# configure loggingifoptions['verbosity']>1:# set root logger to use the DEBUG levelroot_logger=logging.getLogger('')root_logger.setLevel(logging.DEBUG)# set the traceback onoptions['traceback']=Truepiperun=options['piperun']p_run_name,run_folder=get_p_run_name(piperun,return_folder=True)try:p_run=Run.objects.get(name=p_run_name)exceptRun.DoesNotExist:raiseCommandError(f'Pipeline run {p_run_name} does not exist')ifp_run.status!='END':raiseCommandError(f'Pipeline run {p_run_name} has not completed.')measurements_arrow=os.path.join(run_folder,'measurements.arrow')measurement_pairs_arrow=os.path.join(run_folder,'measurement_pairs.arrow')ifos.path.isfile(measurements_arrow):ifoptions['overwrite']:logger.info("Removing previous 'measurements.arrow' file.")os.remove(measurements_arrow)else:raiseCommandError(f'Measurements arrow file already exists for {p_run_name}'' and `--overwrite` has not been selected.')ifos.path.isfile(measurement_pairs_arrow):ifoptions['overwrite']:logger.info("Removing previous 'measurement_pairs.arrow' file.")os.remove(measurement_pairs_arrow)else:raiseCommandError('Measurement pairs arrow file already exists for'f' {p_run_name} and `--overwrite` has not been selected.')logger.info("Creating measurements arrow file for '%s'.",p_run_name)create_measurements_arrow_file(p_run)logger.info("Creating measurement pairs arrow file for '%s'.",p_run_name)create_measurement_pairs_arrow_file(p_run)