Skip to content

Commit

Permalink
[components] create venv when scaffolding code location (#26348)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Run `uv sync` to generate the virutal environment immediately after
scaffolding a code location. This is a more natural place to run it than
the first time you try to e.g. list component types.

## How I Tested These Changes

Unit tests.
  • Loading branch information
smackesey authored Dec 11, 2024
1 parent 2f0c1a3 commit d99edad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python_modules/libraries/dagster-dg/dagster_dg/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def generate_code_location(path: str, editable_dagster_root: Optional[str] = Non
uv_sources=uv_sources,
)

# Build the venv
execute_code_location_command(Path(path), ("uv", "sync"))


def generate_component_type(root_path: str, name: str) -> None:
click.echo(f"Creating a Dagster component type at {root_path}/{name}.py.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def test_generate_code_location_inside_deployment_success() -> None:
assert Path("code_locations/bar/bar_tests").exists()
assert Path("code_locations/bar/pyproject.toml").exists()

# Check venv created
assert Path("code_locations/bar/.venv").exists()
assert Path("code_locations/bar/uv.lock").exists()

# Commented out because we are always adding sources right now
# with open("code_locations/bar/pyproject.toml") as f:
# toml = tomli.loads(f.read())
Expand All @@ -162,6 +166,10 @@ def test_generate_code_location_outside_deployment_success() -> None:
assert Path("bar/bar_tests").exists()
assert Path("bar/pyproject.toml").exists()

# Check venv created
assert Path("bar/.venv").exists()
assert Path("bar/uv.lock").exists()


def _find_git_root():
current = Path.cwd()
Expand Down

0 comments on commit d99edad

Please sign in to comment.