-
Notifications
You must be signed in to change notification settings - Fork 0
IN 1434 - utilize uv script and tool building #12
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
Conversation
Why these changes are being introduced: Where formerly we were using a very low level, manual way of invoking the CLI with 'uv run python -m launcher.cli`, uv provides quite a bit of tooling around invoking a project. Because we invoke the CLI in multiple contexts -- local dev work, Docker container, standalone for running a notebook -- leaning into uv conventions can streamline a lot of that. How this addresses that need: Added a 'project.scripts' section with commands 'marimo-launcher' and 'mitlib-marimo-launcher' (more globally unique) that creates a console entry point for the CLI application. With this in place, we can now change how the CLI is invoked in all contexts: - local dev us 'uv run marimo-launcher' - Docker container installs this project like a library into the system wide python installation - can even support standalone installation and usage with 'uv tool install --from <repository> marimo-launcher' Side effects of this change: * No side effects, just easier invocation Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1434
|
|
||
| [project.scripts] | ||
| marimo-launcher = "launcher.cli:cli" | ||
| mitlib-marimo-launcher = "launcher.cli:cli" |
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.
It'll be interesting to discuss this more as a team.
Now that we can start to theoretically install our CLIs and applications as standalone tools, we may want to consider giving them a namespace prefix like mitlib-*. Imagine we had a tool we called... oh I don't know.... transform (link). This could collide with other linux, homebrew, or a myriad of other scripts on our machines.
If we were to start prefixing our uv tools / entrypoints with mitlib-* we might be able to start to build an ecosystem of terminal / CLI tooling from our own applications.
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.
Good call, looking forward to that discussion!
Pull Request Test Coverage Report for Build 17132166923Details
💛 - Coveralls |
ehanson8
left a comment
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 all looks great, glad we're beginning to develop some uv conventions through this work
|
|
||
| [project.scripts] | ||
| marimo-launcher = "launcher.cli:cli" | ||
| mitlib-marimo-launcher = "launcher.cli:cli" |
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.
Good call, looking forward to that discussion!
Purpose and background context
As outlined in the git commit, this PR leans more heavily into
uvtooling to streamline how this CLI is run locally for development, installed in the Docker container for production use, and even can be used as a standalone "tool" installed directly from the repository.The key section is here in the
pyproject.toml:Though the word "script" is used I think it's more helpful to think of these as "entry points" for the application. And, that this begins to convert this application into something "installable".
Local Development
When developing locally, you can now just run the following:
A build is technically performed each time, but this is quick. Code changes are immediately reflected. Better yet, sneaky errors will pop up if the dependencies in the
pyproject.tomldon't support the project (e.g. a manualpip installwas performed that has a library locally, but wouldn't have been present during build).You can see this usage in the updated
Makefiletesting commands.Docker Image
Installing this CLI as a
uvtool also dramatically simplifies theDockerfile. The key lines here are:We copy the metadata files
pyproject.tomlanduv.lockinto the container, and the application itself at/launcher. Then we quite literally install the application to the system wide python installation, which in a container is an expected and good thing.Now, inside the container, we have a bonafied
marimo-launcherscript/entrypoint/command (whatever you want to call it) that we can call directly. And you can see that we do in the updatedENTRYPOINT.Standalone
uvToolMaybe one of the more exciting things this opens up is the ability to install this CLI as a tool anywhere quite easily. This CLI can now be installed a machine, directly from the Github repository, with a
uv tool install ...command (more on this in the testing section below).How can a reviewer manually see the effects of these changes?
Local Testing
Run the CLI directly:
Run a test notebook (also Makefile command
cli-test-inline-run):Docker Testing
Build image:
Jump into a bash shell of a container and note that
marimo-launcheris installed:Standalone
uvTool TestingArguably the most fun part 😎, install as a standalone
uvtool. Start a new shell, somewhere on your machine completely unassociated with this project.Install the CLI as a tool directly from github (the
@<branch>is just temporary until a merge tomain):Confirm it's installed (similar to inside the Docker container):
Run a notebook that is also in Github!
And to take this principle to the absolute moon, you can run it all as a one liner in a completely isolated and ephemeral way via
uvx(link):Includes new or updated dependencies?
NO
Changes expectations for external applications?
NO
What are the relevant tickets?