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

Use Hatch Environments and Scripts #239

Merged
merged 9 commits into from
Oct 18, 2022

Conversation

RobertRosca
Copy link
Contributor

@RobertRosca RobertRosca commented Sep 28, 2022

PR implements some of the Hatch features mentioned in #209, main ones are:

  • Matrix definitions for incompatible plugins
    • The dev environment is a matrix currently made up of the all combinations of frontends ['lab', 'retro'] and authentication plugins ['noauth', 'auth', 'fief]
    • This lets you have all plugins installed in their own environments, and allows for easy testing/switching between them
    • hatch run dev.lab-noauth:jupyverse spawns jupyverse with jupyterlab with noauth, hatch run dev.retro-fief:jupyverse is retro with fief auth, etc...
  • Docs environment and scripts allow for easy testing/building of docs, e.g. hatch run docs:serve

Docs were updated to explain the above.

Right now this isn't ideal as using context formatting to specify the plugins as dependencies for development didn't work, since Hatch doesn't have an easy mechanism for creating environments with editable dependency installations. So for now this is done with pre/post install commands running pip install on the required plugins.

I've started a discussion on the Hatch repo here pypa/hatch#516 to see if a PR allowing for the easy definition of editable local dependencies would be accepted. If it is then I'd like to wait for that. and remove the workaround calling pip install in the pre/post script sections.

Still to do:

Closes #209

@davidbrochart
Copy link
Collaborator

Thanks a lot @RobertRosca!
I just changed the environment names, it was a bit confusing because we have a lab plugin which is common to the jupyterlab and retrolab plugins, so it's better to keep the exact names jupyterlab and retrolab for the frontend.
I couldn't have e.g. hatch run dev.jupyterlab-noauth jupyverse working, nor hatch -e dev.jupyterlab-noauth shell. It seems that it doesn't install the jupyterlab plugin. Any idea?

@RobertRosca
Copy link
Contributor Author

Part of this is the Hatch syntax. You need a colon between the environment name and the command to be executed, like hatch run dev.jupyterlab-noauth:jupyverse.

But that also doesn't work thanks to come copy/paste fumbling from me 😛, problem was:

[tool.hatch.envs.dev.scripts]
jupyverse = "fps_uvicorn.cli:app"

...

[project.scripts]
jupyverse = "fps_uvicorn.cli:app"

This meant that the bin/jupyverse was correctly created because of the [project.script] section (which defines entry points), but hatch run {env}:jupyverse would call /bin/sh fps_uvicorn.cli:app due to the [envs.*.scripts] section (which defines commands that get called by the shell), causing the issue.

nor hatch -e dev.jupyterlab-noauth shell

I've fixed that now, could you give it another go?

Didn't notice either of these issues since I forgot to run hatch env purge and old environments were being re-used, meaning some changes weren't reflected.

@davidbrochart
Copy link
Collaborator

Awesome, that works!

@davidbrochart
Copy link
Collaborator

davidbrochart commented Oct 12, 2022

It looks like pypa/hatch#484 has been merged and released.
Looking forward to getting this PR in, but there is no rush @RobertRosca, whenever you find time 👍

@RobertRosca
Copy link
Contributor Author

RobertRosca commented Oct 17, 2022

Hey, sorry for the delay, was busy with work last week. I'm debugging the test failures locally, not clear to me why it passes on 3.7 but not on 3.8+ yet (now it is 😛 working on a fix)

Related to that, I'm using act to run tests locally and there is a bug in the setup-miniconda action which means that it fails local executions without setting the version explicitly, which is why I have set it to latest in df2bc3d (#239).

@RobertRosca
Copy link
Contributor Author

Sweet, I rebased off of #241 and tested locally, everything seems to be working now. Once #241 gets merged the issues here should be fixed 👍

@RobertRosca RobertRosca changed the title Add hatch dev/docs sections Use Hatch Environments and Scripts Oct 18, 2022
@RobertRosca RobertRosca marked this pull request as ready for review October 18, 2022 08:42
@davidbrochart
Copy link
Collaborator

This looks great @RobertRosca, this will improve Jupyverse's workflow management so much!
I just tried hatch run dev.jupyterlab-noauth:jupyverse, and got:

fps_uvicorn.cli:app: not found

@RobertRosca
Copy link
Contributor Author

Oops, screwed up when rebasing and re-introduced #239 (comment)

It should work now, could you give it another go?

@davidbrochart
Copy link
Collaborator

Yes, it works fine now!

@davidbrochart
Copy link
Collaborator

Just a minor update to docs, and I think it's good to go!
Do you want to squash a little bit, especially to get rid of 1653b7e?

@RobertRosca
Copy link
Contributor Author

Oh yes, I'll go ahead and do that

@RobertRosca
Copy link
Contributor Author

Could also just do a squash merge, don't think anything too important would be lost from the commit log from this

@davidbrochart
Copy link
Collaborator

I think you deserve more credit, thanks a lot for your contribution @RobertRosca !
It looks like tests hang on windows for python >=3.8, I'll merge and investigate later.

@davidbrochart davidbrochart merged commit 261ee43 into jupyter-server:main Oct 18, 2022
@ofek
Copy link

ofek commented Oct 29, 2022

Awesome job!

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.

Changing Build Backend (to Hatch?)
3 participants