Skip to content

Jetbase run anywhere#92

Open
Naelpuissant wants to merge 9 commits into
jetbase-hq:mainfrom
Naelpuissant:jetbase-run-anywhere
Open

Jetbase run anywhere#92
Naelpuissant wants to merge 9 commits into
jetbase-hq:mainfrom
Naelpuissant:jetbase-run-anywhere

Conversation

@Naelpuissant

@Naelpuissant Naelpuissant commented May 10, 2026

Copy link
Copy Markdown

PR Description

Overview

Hello ! Thanks for the tool, I like the simplicity of it but the cd jetbase feels a bit painfull.

This PR updates Jetbase so CLI commands can run from any directory that contains or is under a directory containing a jetbase folder.

Previously, commands required the user to be inside the jetbase directory.


Changes Made

Code

  • Create get_jetbase_directory and get_migrations_directory to find the root directory by looking at jetbase folder.
  • Updated validate_jetbase_directory() docstring to reflect that it validates a jetbase directory in the current path or parent directories.
  • Corrected the test description in test_validation.py to state that validation searches the directory tree rather than requiring the current directory to be named jetbase.

Documentation

Removed outdated instructions and notes that required users to run commands from inside the jetbase directory.

Tests

Added some unit tests, looks fine but I didn't run other tests for now.
I'm thinking about removing the os.chdir('jetbase') from integration tests if I can run those.


Implementation Details

The root detection now works by:

  1. Checking if the current directory is named jetbase
  2. Checking if jetbase exists in the current directory
  3. Walking up parent directories to find jetbase
  4. Raising DirectoryNotFoundError if not found

Note

I was thinking about using the pyproject.toml file as "anchor" while trying to find the jetbase dir but idk since for monorepo we could have only one pyproject and multiple jetbases

@Naelpuissant Naelpuissant force-pushed the jetbase-run-anywhere branch from 4f87e0d to 67b6e2e Compare May 11, 2026 01:06
@jaz-alli

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! I'll have time to take a look at this tomorrow

@jaz-alli

jaz-alli commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Hey, really sorry for the wait. This is a great idea to run jetbase commands from anywhere! Thanks for working on it!

I took a closer look at the PR, and I think there are a few changes that would be needed before this can be merged:

  1. The directories.py file was placed in the commands folder, but it is not a jetbase cli command. It should be moved out.

  2. There is simple logic in the find_pyproject_toml function in config.py to find the pyproject.toml file. That logic can be reused to find the jetbase directory instead of using a different way. It would also be easier for maintenance.

  3. There are a few bugs that were missed. The upgrade and status commands still call the current working directory, so they can fail.

  4. Some of the tests that raise exceptions have assert statements that cannot be reached because they are placed after the exception is raised.

Overall, I think the idea is useful, but the implementation needs some cleanup before it can be merged. Thanks again for the contribution!

@Naelpuissant

Copy link
Copy Markdown
Author

Thank you for the review, I'll clean this up !

  1. There is simple logic in the find_pyproject_toml function in config.py to find the pyproject.toml file. That logic can be reused to find the jetbase directory instead of using a different way. It would also be easier for maintenance.

This would implies that the user should have a pyproject.toml as an anchor to be able to use jetbase from anywhere, are we ok on this ?

@Naelpuissant Naelpuissant marked this pull request as draft June 18, 2026 00:14
- use get_migrations_directory in upgrade/status commands
- allow to provide an optional migration directory to repeatable helpers
- fix related tests
@Naelpuissant Naelpuissant force-pushed the jetbase-run-anywhere branch from 475feff to 06f28f2 Compare June 18, 2026 02:39
@Naelpuissant Naelpuissant force-pushed the jetbase-run-anywhere branch from 06f28f2 to 0eb23b3 Compare June 18, 2026 02:42
@Naelpuissant

Naelpuissant commented Jun 18, 2026

Copy link
Copy Markdown
Author

PR updated, waiting for your answer on the mandatory pyproject.toml anchor or not.

I have locally tested :

  • JETBASE_SQLALCHEMY_URL=sqlite:///dummy.db uv run pytest tests/cli
  • uv run pytest tests/unit

I didn't ran integration tests (regarding those I find it a bit misleading having test_integration and integration folders)

for precommit, I've added it to the dev deps but maybe having pyrefly not pyrefly-typecheck-system (system wide) and using specific version might be relevant here, what do you think ?

@Naelpuissant Naelpuissant marked this pull request as ready for review July 3, 2026 06:28
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.

2 participants