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

Add a "usage" session to nox #2022

Merged
merged 5 commits into from
Dec 13, 2022
Merged

Conversation

ThomasLaPiana
Copy link
Contributor

@ThomasLaPiana ThomasLaPiana commented Dec 10, 2022

Closes #1618

Code Changes

  • add a session for nox that prints the entire docstring for a given session

Steps to Confirm

  • follow the examples given below and confirm everything works

Pre-Merge Checklist

  • All CI Pipelines Succeeded Nothing here should affect any CI jobs or code logic
  • Documentation Updated:
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Description Of Changes

Using the standard nox command to list out all available sessions is nice and all, but it only shows the first line and isn't practical for showing in-depth information. Many session should contain a lot of usage information due to the complexity of the command given and this new session will allow us to do just that.

Example

No posargs provided

fides> nox -s usage 
Docker version 20.10.21, build baeda1f
nox > Running session usage
nox > Re-using existing virtual environment at .nox\usage.
nox > Session usage aborted: Please provide a session name.

Invalid session name provided

fides> nox -s usage -- foo
Docker version 20.10.21, build baeda1f
nox > Running session usage
nox > Re-using existing virtual environment at .nox\usage.
nox > Session usage aborted: Sorry, this isn't a valid nox session.

Valid session provided

fides> nox -s usage -- clean
Docker version 20.10.21, build baeda1f
nox > Running session usage
nox > Re-using existing virtual environment at .nox\usage.
nox > 
    Clean up docker containers, remove orphans, remove volumes
    and prune images related to this project.
    
nox > Session usage was successful.

@ThomasLaPiana ThomasLaPiana self-assigned this Dec 10, 2022
@ThomasLaPiana ThomasLaPiana marked this pull request as ready for review December 12, 2022 07:12
Copy link
Contributor

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

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

It's working for me, just one non-blocking question. How closely does this need to match to the output of nox? When running nox you get options like pytest_ops(unit).

Then nox -s usage -- pytest_ops(unit) gives missing delimiter for 'u' glob qualifier and nox -s usage -- "pytest_ops(unit)" gives Session usage aborted: Sorry, this isn't a valid nox session.. nox -s pytest_ops does work.

Copy link
Contributor

@TheAndrewJackson TheAndrewJackson left a comment

Choose a reason for hiding this comment

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

Everything worked as described. I'm also seeing what Paul mentioned. nox -s usage -- "build(dev)" is returning

Docker version 20.10.21, build baeda1f
nox > Running session usage
nox > Re-using existing virtual environment at .nox\usage.
nox > Session usage aborted: Sorry, this isn't a valid nox session.

I can see someone trying to test out that style of command. Maybe it would be possible to detect those sub commands and output the usage info for just that one. I agree that this is non blocking though 👍

@ThomasLaPiana
Copy link
Contributor Author

It's working for me, just one non-blocking question. How closely does this need to match to the output of nox? When running nox you get options like pytest_ops(unit).

Then nox -s usage -- pytest_ops(unit) gives missing delimiter for 'u' glob qualifier and nox -s usage -- "pytest_ops(unit)" gives Session usage aborted: Sorry, this isn't a valid nox session.. nox -s pytest_ops does work.

This is expected behviour, as it is printing the docstring for a single session (which is a function). There aren't separate docstrings for each parameter, so one must use the session name directly without any specific parameters. nox -s pytest_ops is actually a valid session, it will run that session with each parameter.

For instance after I run a nox -s clean I then run nox -s build and it builds everything in one go

@ThomasLaPiana ThomasLaPiana merged commit 2eef8f0 into main Dec 13, 2022
@ThomasLaPiana ThomasLaPiana deleted the ThomasLaPiana-nox-usage-session branch December 13, 2022 04:38
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.

Add usage session for Nox commands
3 participants