-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add job script validations #310
Conversation
# | ||
# Find.find returns an enumerator - the first path is always the initial directory | ||
# so we return the array with the first item omitted | ||
# Then, map files to WorkflowFile objects | ||
# | ||
# @return [WorkflowFile] An array of WorkflowFile Objects of all the files of a directory | ||
def folder_contents |
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.
could cache this like:
def folder_contents
return @folder_contents if defined? @folder_contents
...
end
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.
This actually only works if you set the @folder_contents otherwise. For example:
def folder_contents
return @folder_contents if defined? @folder_contents
if File.directory?(self.staged_dir)
@folder_contents = Find.find(self.staged_dir).drop(1).select {|f| File.file?(f) }.map {|f| WorkflowFile.new(f, self.staged_dir)}
else
@folder_contents = []
end
end
Thank you for your feedback! I cleaned up the code and added error handling for the file permission. Another issue I had is that the titles for option groups will still be displayed when no options available under that group. It's handled by removing empty option groups. |
Thank you for the feedback and help identify the script directives! I updated |
def has_resource_manager_directive? | ||
begin | ||
contents = File.open(path) { |f| f.read(1000) } | ||
contents && (contents.include?("#PBS") || contents.include?("#SBATCH") || contents.include?('#BSUB') || contents.include?('#$')) |
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.
For the contents.include?
predicate I would prefer:
['#PBS', '#SBATCH', '#BSUB', '#$'].any?{ |directive| contents.include?(directive) }
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.
Although this is fine as is: a better design here would be for ood_core
's Adapters to provide their directive as a constant and for this array to be built from the available clusters. The more tests we have the more likely we are to get a false positive.
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.
Just noticed OSC/ood_core#161. +1
@@ -255,7 +285,7 @@ def stop_machete_jobs(jobs) | |||
end | |||
end | |||
end | |||
|
|||
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.
Pointless whitespace...
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.
This works for me.
- Ideally we would build the list of resource manager directives from
OODClusters
afterood_core
has been updated. - While this is a good start the workflow to get to here is not what I would expect as a user. I would expect that when creating a new workflow from an existing directory I would be able to select my script there. We could add this to the
new_from_path
view by adding some JS to listen to the change event onworkflow[staging_template_dir]
, and then updating the script select options via AJAX.
Those changes can be a separate PR.
Overview
Add job script validation and provide recommendation for users
Step1: Omit files larger than 65KB for this field
Step2: Group files to "suggested" and "others" and sort alphabetically
Suggested files meet any of the following criteria
1. File name extension is one of
[".sh", ".job", ".slurm", ".batch", ".qsub", ".sbatch", ".srun", ".bsub"]
2. First line of the file is a shebang line
3. First 1000 bytes of the file contain '#PBS' or '#SBATCH"
Others files are files not omitted in Step1 and not meet requirement to be suggested
Tests
Fixes #105