Skip to content

Commit

Permalink
add blueprints example
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed Jun 21, 2024
1 parent ca2c98d commit e03972f
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .definitions import defs as defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pathlib import Path
from typing import Sequence

from dagster import PipesSubprocessClient
from dagster_blueprints import YamlBlueprintsLoader
from dagster_blueprints.shell_command_blueprint import ShellCommandBlueprint

blueprints_path = Path(__file__).parent / "pipelines"

loader = YamlBlueprintsLoader(
per_file_blueprint_type=Sequence[ShellCommandBlueprint], path=blueprints_path
)
defs = loader.load_defs(
resources={"pipes_subprocess_client": PipesSubprocessClient(cwd=str(blueprints_path))},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pandas as pd

customers = pd.read_csv("../../data/customers.csv")

num_customers = customers.shape[0]
num_steves = customers[customers["FIRST_NAME"] == "Steve"].shape[0]
customer_stats = pd.DataFrame({"num_customers": [num_customers], "num_steves": [num_steves]})

customer_stats.to_csv("../../data/customer_stats.csv", index=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- command: "curl -o ../../data/customers.csv https://raw.githubusercontent.com/dagster-io/dagster/master/docs/next/public/assets/customers.csv"
assets:
- key: customers

- command: "python customer_stats.py"
assets:
- key: customer_stats
deps: [customers]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.dagster]
module_name = "builtin_blueprints"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
name = builtin_blueprints
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import find_packages, setup

setup(
name="builtin-blueprints",
packages=find_packages(exclude=["builtin-blueprints"]),
install_requires=[
"dagster",
"dagster-blueprints",
"dagster-webserver",
"pandas",
],
extras_require={"dev": ["pytest"]},
)
2 changes: 1 addition & 1 deletion examples/experimental/dagster-blueprints/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_version() -> str:
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
],
packages=find_packages(exclude=["dagster_blueprints_tests*"]),
packages=find_packages(exclude=["dagster_blueprints_tests*", "examples*"]),
install_requires=[
f"dagster{pin}",
f"dagster-databricks{pin}",
Expand Down

0 comments on commit e03972f

Please sign in to comment.