Skip to content

Commit 4978a6f

Browse files
duragdatadudeKLongeravenac95
authored
Poetry --> UV (+ Makefile Added) (#22)
* chore: update lint-staged configuration and pyproject.toml - Change command in .lintstagedrc from 'poetry run ruff' to 'uv run ruff' - Migrate from [tool.poetry] to [project] section in pyproject.toml - Update authors and license format in pyproject.toml - Add dependencies under [project] and [project.optional-dependencies] sections - Switch build system from poetry to hatchling * chore: remove poetry.lock file - Deleted the poetry.lock file as part of the transition to a new dependency management approach. * chore: simplify dagster-dev command in Makefile - Removed the clean-dagster target to streamline the dagster-dev command. - Updated the dagster-dev command to remove the explicit workspace.yaml path, allowing for default behavior. * chore: update CI workflow to use uv for dependency management - Replaced Poetry setup with actions/setup-python for Python installation. - Added installation step for uv and updated commands to use uv for running checks and tests. - Streamlined the CI process by integrating uv for dependency synchronization and execution of tasks. * chore: enhance development setup with Makefile commands - Added `pyright` command to Makefile for type checking. - Updated `pyright` script in package.json to use the correct Python path. - Revised README to reflect the new Make commands for initializing and upgrading dependencies. - Simplified instructions for running tests and the sample dagster project using Make commands. * Update pyproject.toml Co-authored-by: Reuven Gonzales <[email protected]> * Update package.json Co-authored-by: Reuven Gonzales <[email protected]> * chore: streamline Makefile for consistent Python command usage - Removed OS-specific checks for Windows in the Makefile. - Unified Python, SQLMESH, and UV command definitions for a cleaner setup. - Simplified activation and deactivation commands for the virtual environment. * chore: update pyproject.toml and console.py for linter integration - Added Pyright exclusion patterns in pyproject.toml to ignore specific directories. - Introduced a new method `show_linter_violations` in EventConsole to handle and publish linting violations. - Reorganized imports in console.py for better clarity and consistency. --------- Co-authored-by: Kevin Longe <[email protected]> Co-authored-by: Reuven Gonzales <[email protected]>
1 parent 987dc46 commit 4978a6f

File tree

9 files changed

+2080
-3531
lines changed

9 files changed

+2080
-3531
lines changed

.github/workflows/ci-default.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,31 @@ jobs:
5252
- recursive: true
5353
args: [--frozen-lockfile, --strict-peer-dependencies]
5454
55-
- name: "Setup Python, Poetry and Dependencies"
56-
uses: packetcoders/action-setup-cache-python-poetry@main
55+
- name: Setup Python
56+
uses: actions/setup-python@v5
5757
with:
5858
python-version: ${{ matrix.python_version }}
59-
poetry-version: 1.8.2
59+
60+
- name: Install uv
61+
uses: astral-sh/setup-uv@v3
62+
63+
- name: Install dependencies
64+
run: |
65+
uv sync --all-extras
6066
6167
- name: Type Check (Python)
6268
run: |
6369
pnpm pyright
6470
6571
- name: Lint (Python)
6672
run: |
67-
poetry run ruff check
73+
uv run ruff check
6874
6975
- name: Test (Python)
7076
run: |
71-
poetry run pytest
77+
uv run pytest
7278
7379
- name: Run the sample dagster project
7480
run: |
75-
poetry run dagster job execute -f sample/dagster_project/definitions.py -j all_assets_job
81+
uv run dagster job execute -f sample/dagster_project/definitions.py -j all_assets_job
7682

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"**/*.py": [
3-
"poetry run ruff check --fix --force-exclude",
3+
"uv run ruff check --fix --force-exclude",
44
"pnpm pyright"
55
]
66
}

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# System detection
2+
UNAME := "$(shell uname)"
3+
PYTHON_VENV_NAME := ".venv"
4+
5+
# Python virtual environment settings
6+
VENV_NAME := .venv
7+
PYTHON := python
8+
9+
PYTHON_CMD := $(CURDIR)/$(VENV_NAME)/bin/python
10+
SQLMESH_CMD := $(CURDIR)/$(VENV_NAME)/bin/sqlmesh
11+
UV_CMD := uv
12+
ACTIVATE := source $(CURDIR)/$(VENV_NAME)/bin/activate
13+
DEACTIVATE := deactivate
14+
15+
init-python:
16+
@if [ ! -d "$(PYTHON_VENV_NAME)" ]; then \
17+
echo "Creating virtual environment with Python 3.12..."; \
18+
uv venv --python 3.12 $(PYTHON_VENV_NAME); \
19+
fi
20+
21+
install-python-deps:
22+
uv sync --all-extras
23+
24+
upgrade-python-deps:
25+
uv lock --upgrade
26+
make install-python-deps
27+
28+
install-node-deps:
29+
pnpm install
30+
31+
upgrade-node-deps:
32+
pnpm update
33+
34+
# Base commands
35+
init: init-python install-python-deps check-pnpm install-node-deps
36+
37+
clean:
38+
find . \( -type d -name "__pycache__" -o -type f -name "*.pyc" -o -type d -name ".pytest_cache" -o -type d -name "*.egg-info" \) -print0 | xargs -0 rm -rf
39+
40+
# Testing commands
41+
test:
42+
$(PYTHON_CMD) -m pytest -vv --log-cli-level=INFO $(filter-out $@,$(MAKECMDGOALS))
43+
44+
pyright:
45+
pnpm pyright
46+
47+
# Sample project commands
48+
49+
dagster-dev: clean-dagster
50+
DAGSTER_HOME=$(CURDIR)/sample/dagster_project $(PYTHON_CMD) -m dagster dev -h 0.0.0.0 -w
51+
52+
dev: dagster-dev # Alias for dagster-dev
53+
54+
dagster-materialize:
55+
$(PYTHON_CMD) -m dagster asset materialize -f sample/dagster_project/definitions.py --select '*'
56+
57+
.PHONY: init init-python install-python-deps upgrade-python-deps clean test mypy check-pnpm install-node-deps upgrade-node-deps sample-dev dagster-dev dagster-materialize clean-dagster

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,33 @@ _Note: this is a python project but some of our dependent tools are in typescrip
5555

5656
### Installing
5757

58-
To install everything you need for development just do the following:
58+
The project uses Make commands to simplify the development setup process. To get started:
5959

6060
```bash
61-
poetry install
62-
pnpm install
61+
make init
62+
```
63+
64+
This will:
65+
- Set up a Python virtual environment with Python 3.12
66+
- Install all Python dependencies
67+
- Install Node.js dependencies via pnpm
68+
69+
_Note: All Make commands automatically use the correct virtual environment - you don't need to activate it manually._
70+
71+
To upgrade dependencies:
72+
```bash
73+
make upgrade-python-deps # Upgrade Python dependencies
74+
make upgrade-node-deps # Upgrade Node.js dependencies
6375
```
6476

6577
### Running tests
6678

6779
We have tests that should work entirely locally. You may see a `db.db` file appear in the root of the repository when these tests are run. It can be safely ignored or deleted.
6880

69-
We run tests with `pytest` like so:
81+
To run tests:
7082

7183
```bash
72-
poetry run pytest
84+
make test
7385
```
7486

7587
### Running the "sample" dagster project
@@ -79,13 +91,17 @@ accompanying sqlmesh project from `sample/sqlmesh_project` configured as an
7991
asset. To run the sample dagster project deployment with a UI:
8092

8193
```bash
82-
poetry run dagster dev -h 0.0.0.0 -f sample/dagster_project/definitions.py
94+
make dagster-dev
95+
```
96+
or
97+
```bash
98+
make dev
8399
```
84100

85101
If you'd like to materialize the dagster assets quickly on the CLI:
86102

87103
```bash
88-
dagster asset materialize -f sample/dagster_project/definitions.py --select '*'
104+
make dagster-materialize
89105
```
90106

91107
_Note: The sqlmesh project that is in the sample folder has a dependency on a

dagster_sqlmesh/console.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1+
import logging
12
import typing as t
2-
from typing import Dict, Union, Callable
3-
from dataclasses import dataclass
4-
import uuid
53
import unittest
6-
import logging
4+
import uuid
5+
from dataclasses import dataclass
6+
from typing import Callable, Dict, Union
77

88
from sqlglot.expressions import Alter
99
from sqlmesh.core.console import Console
10-
from sqlmesh.core.plan import EvaluatablePlan
1110
from sqlmesh.core.context_diff import ContextDiff
12-
from sqlmesh.core.plan import PlanBuilder
13-
from sqlmesh.core.table_diff import RowDiff, SchemaDiff, TableDiff
1411
from sqlmesh.core.environment import EnvironmentNamingInfo
12+
from sqlmesh.core.linter.rule import RuleViolation
13+
from sqlmesh.core.plan import EvaluatablePlan, PlanBuilder
1514
from sqlmesh.core.snapshot import (
1615
Snapshot,
1716
SnapshotChangeCategory,
1817
SnapshotInfoLike,
1918
)
19+
from sqlmesh.core.table_diff import RowDiff, SchemaDiff, TableDiff
2020
from sqlmesh.utils.concurrency import NodeExecutionFailedError
2121

2222
logger = logging.getLogger(__name__)
@@ -562,6 +562,12 @@ def print_environments(self, environments_summary: t.Dict[str, int]) -> None:
562562
def show_table_diff_summary(self, table_diff: TableDiff) -> None:
563563
self.publish(ShowTableDiffSummary(table_diff))
564564

565+
def show_linter_violations(
566+
self,
567+
violations: list[RuleViolation],
568+
) -> None:
569+
self.publish(LogWarning("Linting violations found", str(violations)))
570+
565571

566572
class DebugEventConsole(EventConsole):
567573
"""A console that wraps an existing console and logs all events to a logger"""

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"build": "turbo run build --concurrency=100%",
1414
"format:staged": "lint-staged",
15-
"pyright": "pyright --pythonpath $(poetry env info --path)/bin/python",
15+
"pyright": "uv run -q -c \"import sys; print(sys.executable)\" | xargs -r pyright --pythonpath",
1616
"prepare": "husky install"
1717
},
1818
"devDependencies": {

0 commit comments

Comments
 (0)