-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conditional outputs#303 #549
Conversation
…ing file name generation
…le1tool to generate output files and validate generation boutiques#303
Hi @DarrinFong, tests are currently failing, would you like to have a look? |
Release 0.5.22.post2
tools/python/boutiques/localExec.py
Outdated
parsedExp.append(word) | ||
# If expression is true, set fileName | ||
# Stop checking (if-elif...) | ||
if " ".join("{0}".format(w) for w in parsedExp) == "default": |
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.
I may be reading this wrong, but aren't what you have written on #L1078 (parsedExp = ["False"]
) and what you're checking here, ( .... == "default"
) incompatible, so defaults would never be added? You know what's going on in here much better than I, @DarrinFong, so please just double check and let me know :)
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.
if word in in_out_dict:
# in_out_dict are k:v pairs that will be in the output of simulate
elif word in all_ids:
parsedExp = ["False"]
break
The elif block should only 'falsify' the expressions that contain an ID which is both:
- in descriptor's inputs/output-files IDs
- NOT in selected values for simulate
Which means the only way for 'default'
to be evaluated False
is when an ID of name 'default'
is present in the descriptor's inputs/output-files IDs. (This raises a concern of whether we have to add 'default'
to the list of invalid IDs).
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.
Great - thank you for the clarification :)
I do think that maybe we want to add "default" as a restricted word in the schema so that it can't be used as an ID... @glatard, thoughts?
Hey @DarrinFong - I added some comments. Overall, this looks awesome! Thanks so much :) |
…ession variables exist in descriptor inputs/output-files). Added unit tests for those.
…perties (review), attempting check variable against type of input for CPT's expressions
@DarrinFong - want to investigate why this is failing, and we can re-review once that is fixed? Thanks! |
…or: invalid keywords, cross-type comparison. Unit test created
…ents checkfor and/or. Updated schema description for conditional path template
…nal_outputs#303 Merging commit into branch to fix broken travis, caused by defining python specific dependencies
…ng/boutiques into conditional_outputs#303
tools/python/requirements.txt
Outdated
docopt==0.6.2 | ||
nexus-sdk; | ||
python_version >= '3.5'; |
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 will break installation from pypi for Python<3.5. The solution has to work with the following install command:
pip install -r requirements.txt
For Python<3.5.
The nexus line should be written as:
nexus-sdk; python_version >= '3.5'
@gkiar Hey Greg, can you take a look at the conditions validation you mentioned in a conversation above? |
tools/python/boutiques/validator.py
Outdated
@@ -58,6 +62,82 @@ def inById(i): | |||
return descriptor["inputs"][inputGet("id").index(i)] | |||
return {} | |||
|
|||
def conditionalExpFormat(s): |
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 function appears to exist in both localExec.py
and validator.py
, so perhaps we could move it to a utils
file and import it?
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.
Function moved to utils.py!
tools/python/boutiques/validator.py
Outdated
@@ -22,6 +23,9 @@ def validate_descriptor(json_file, **kwargs): | |||
""" | |||
path, fil = op.split(bfile) | |||
schema_file = op.join(path, "schema", "descriptor.schema.json") | |||
allowed_keywords = ['and', 'or', 'false', 'true'] |
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.
Because capitalization may be funny/distinct across representations (in particular True
versus true
), we may want to either a) add more capitalizations to this list, or b) convert everything to an upper/lowercase value when we compare. Essentially just an extra precaution to avoid the hole of evaluating a JSON true
and a boolean Python True
to be distinct.
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.
I opted for option b), just in case someone needs to write ANd
😄
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.
Hey @DarrinFong - thanks for this! It looks awesome, I'm really excited to have this rolled in 😄
I left a few comments, but they're all minor and non-blocking if you're too swamped to get to them/we can just create issues to tie up the ends. Lmk if what you think!
Thanks again :D
… Moved redundant condiitonalExpFormat into utils.py
Purpose
Enables Conditional-path-template in descriptor's output-files. CPT will contain a list of objects whose key represents a boolean expression (python syntax), the first true expression's corresponding path will be selected (top down). If the output-file is required, a
default
key is must be included in the list of CPT.PT and CPT are mutex properties within an output-file
Current behaviour
New behaviour