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

Get session list in code #719

Open
lhupfeldt opened this issue Jun 23, 2023 · 3 comments
Open

Get session list in code #719

lhupfeldt opened this issue Jun 23, 2023 · 3 comments

Comments

@lhupfeldt
Copy link

How would this feature be useful?

I would like to get the list of sessions from within a session in the noxfile. I use the session list to generate json (with further options) for integration with jenkins pipelines.

Describe the solution you'd like

Expose Manifest.list_all_sessions(self) -> Iterator[tuple[SessionRunner, bool]] as a function in the nox module.

Describe alternatives you've considered

I looked at the code, but it seems that it is not simple to get the list.

Anything else?

No response

@henryiii
Copy link
Collaborator

henryiii commented Apr 6, 2024

Nox supports json output for the session list for the last couple of releases. You can process with jq or Python. Is that fine? Sounds like exactly what you need.

@lhupfeldt
Copy link
Author

This is exactly what i don't want. I don't want to invoke a new nox process from within a nox session. The same data available from the command line as json, should be available as a python dict or as Iterator[tuple[SessionRunner, bool]] or similar with a single function call within an existing nox process.

@Walter-Gates-Bose
Copy link

I would find this useful as well. I am trying to write a session that will create lock files with pip-tools and want one lock file per session. It would be useful to not have to call nox from within nox; I either have to install nox within that session or make sure nox can be found outside that session.

@henryiii, The nox --list-sessions --json output is constrained when nox.options.sessions is used to just those sessions in that list, that makes it potentially less useful for automation purposes than I think it was intended. I can get around it because I don't want to create a lock file for the session that creates lockfiles using nox -k "not lock" --list-session --json, but others might not.

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

No branches or pull requests

3 participants