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

womtool/miniwdl validate command #265

Merged
merged 17 commits into from
Sep 13, 2023
Merged

womtool/miniwdl validate command #265

merged 17 commits into from
Sep 13, 2023

Conversation

bshifaw
Copy link
Collaborator

@bshifaw bshifaw commented Jul 20, 2023

Added a command that validates wdl workflows using miniwdl package
Updated HelloWorld.wdl to verison1.0

@bshifaw bshifaw self-assigned this Jul 20, 2023
@bshifaw bshifaw linked an issue Jul 20, 2023 that may be closed by this pull request
@bshifaw bshifaw requested a review from lbergelson July 20, 2023 18:30
@bshifaw bshifaw changed the title miniwdl validate command womtool/miniwdl validate command Jul 24, 2023
@@ -1,3 +1,5 @@
version 1.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated wdl to verison 1.0


String docker
# Runtime Options:
Int mem
Copy link
Collaborator Author

@bshifaw bshifaw Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miniwdl failed this workflow because it didn't like operating on optional int with an int
mem * 1024
So made it none optional

@lbergelson
Copy link
Member

I would consider running both validations by default. And doing both pre-submit.

f = io.StringIO()
with redirect_stdout(f):
# Importing miniwdl.check here to help with stdout redirection
from WDL.CLI import check as miniwdl_check
Copy link
Collaborator Author

@bshifaw bshifaw Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of importing in the middle of the script but this seemed the only way the stdout redirection would work. If not imported here miniwdl's linting function will print out several warnings. Which isn't helpful when running the function in the submit command

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miniwdl just dumps all it's output to stdout then I'm assuming? This seems like a sane way to capture it.

)

captured_outputs = f.getvalue()
except Exception as exn:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here i wanted to capture any exception from miniwdl, mainly to reprint it in a cleaner way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems good to me. Definitely better to standardize them.

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bshifaw I have a few comments but otherwise this looks great. Thank you.

@@ -168,15 +169,16 @@ def print_version():
main_entry.add_command(alias.main)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a note to keep these alphabetical?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

+ ("\n".join(validate_status["errors"]))
)

LOGGER.debug("Skipping validation of WDL plus a dependencies zip")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no one working on fixing this particular cromwell issue is there? Should we poke them?

)

captured_outputs = f.getvalue()
except Exception as exn:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems good to me. Definitely better to standardize them.

captured_outputs = f.getvalue()
except Exception as exn:
# Importing miniwdl.print_error here to help with stdout redirection
from WDL.CLI import print_error as miniwdl_print_error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still under the stdout redirect in this scope?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

f = io.StringIO()
with redirect_stdout(f):
# Importing miniwdl.check here to help with stdout redirection
from WDL.CLI import check as miniwdl_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miniwdl just dumps all it's output to stdout then I'm assuming? This seems like a sane way to capture it.

# Importing miniwdl.check here to help with stdout redirection
from WDL.CLI import check as miniwdl_check

miniwdl_check(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming miniwdl doesn't offer a clean way to get the results without just scraping the output logs? It would be cleaner if we didn't have to do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know of, having it directed to a variable didn't do anything

@click.command(name="validate")
@click.argument("wdl", type=click.Path(exists=True), required=True)
@click.argument("wdl_json", type=click.Path(exists=True), required=False)
@click.option(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In submit this is "--dependencies-zip. We should probably make this match. (Or maybe we should change it in submit?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miniwdl allows users to provide more than one folder to look for dependencies.
I can make it match the submitcommand so that users can only provide one folder (or zip) to send to miniwdl.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, so now you can provide a zip or a path to a directory and it will provide it to miniwdl. I noticed that it doesn't handle nested workflows well (when the main workflow is in a child directory separate from its imported workflows). However it should be possible to reuse the same logic in the nested wdl PR to resolve it.

@lbergelson
Copy link
Member

My comments are all basically questions, only real actionable thing is changing the argument name.

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

type=click.Path(exists=True),
help="MiniWDL option: Directory containing workflow source files that are "
"used to resolve local imports. (can supply multiple times)",
help="MiniWDL option: ZIP file or directory containing workflow source files "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessible to... what? WHAT is it accessible to? The mystery is killing me! :)

@@ -89,9 +89,11 @@ def main(
wdl=str(wdl), wdl_json=str(wdl_json), config=config
)

# Todo: Have it support nested directories after PR 268 is merged
# https://github.com/broadinstitute/cromshell/pull/268
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


# Define a temporary directory for testing
@pytest.fixture(scope="function")
def temp_dir():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest fixtures are neat.

@bshifaw bshifaw merged commit b32c718 into main Sep 13, 2023
8 checks passed
@bshifaw bshifaw deleted the bs_add_validate branch September 13, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to add a command to validate WDLs through cromshell.
2 participants