Skip to content
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

Extend PipelineTasks to facilitate creating directories and moving/copying files #759

Open
pjbriggs opened this issue Feb 18, 2022 · 0 comments

Comments

@pjbriggs
Copy link
Member

Proposal to extend the PipelineTask class in the pipeliner module to make it easier to create directories, and move or copy files created by the task. These would be most useful for removing boilerplate code from the task-specific finish methods, where often it seems necessary to know explicitly where files have been created by the task.

For example, something like:

if not os.path.exists(self.args.out_dir):
    os.makedirs(self.args.out_dir)

could be replaced by:

self.makedirs(self.args.out_dir)

which could provide a consistent interface and wrap all the required checks.

Another example:

for output in expected_outputs:
    f = "%s.%s" % (self.args.name,output)
    if os.path.exists(os.path.join(self.args.out_dir,f)):
        continue
    else:
        if os.path.exists(f):
            shutil.copy(f,self.args.out_dir)

could be replaced by something like:

for output in expected_outputs:
   self.export_file("%s.%s" % (self.args.name,output),self.args.out_dir)

By convention, relative paths would be considered to be within the task working directory (absolute paths would be used as-is). It might also be useful if the pipeline infrastructure was extended to run each job in a dedicated working directory.

Additional optional arguments could be provided e.g. to avoid overwriting existing files etc.

Other potentially useful methods might be to check for the existence of files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant