The workshop slides are available here: https://amantaya.github.io/CowsCode26-Orchestration/slides/workshop.html#/title-slide
This repository is a complete starter kit for a 1-hour workshop aimed at R-first research teams working with Precision Livestock Technology (PLT).
- Dagster scaffold with assets, jobs, schedules, and a file-watching sensor
- Accelerometer CSV ingestion pipeline (DuckDB-backed)
- Movement-intensity summarisation and PNG plot generation
- Weather API materialization demo asset
- Python helper to run R scripts through subprocess (
Rscript) - Quarto slideshow source for workshop delivery
- GitHub Pages workflow to publish workshop content
.
├─ src/dagster_livestock_workshop/
│ ├─ assets.py
│ ├─ schedules.py
│ ├─ definitions.py
│ └─ r_runner.py
├─ scripts/
│ ├─ write_data_duckdb.R
│ ├─ plot_movement_intensity.R
│ ├─ fetch_weather_open_meteo.R
│ └─ summarize_weather_open_meteo.R
├─ data/
│ └─ Ingest/ ← drop accelerometer CSVs here
├─ slides/
│ └─ workshop.qmd
├─ run_r_subprocess.py
├─ _quarto.yml
└─ .github/workflows/publish-quarto.yml
- Python 3.10+
- R with
Rscriptavailable on PATH - R packages:
duckdb,DBI - Quarto CLI (for local slide rendering)
- UV package manager
Install R packages:
install.packages(c("duckdb", "DBI"))Install UV (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"On Windows:
uv venv
.\.venv\Scripts\Activate.ps1
uv syncOn Mac/Linux:
uv venv
source .venv/bin/activate
uv syncDagster is already declared in pyproject.toml and is installed by uv sync.
To verify:
uv run dagster --versionOptional (if you want to add/upgrade Dagster packages explicitly):
uv add dagster dagster-webserver
uv syncuv run dagster dev -m dagster_livestock_workshop.definitionsDagster UI typically opens at http://127.0.0.1:3000.
- Copy accelerometer CSV files into
data/Ingest/. - In Dagster UI, open asset
accelerometer_data_to_duckdb. - Click Materialize.
- Show metadata and output file:
data/accelerometer.duckdb.
- Open asset
movement_intensity(depends onaccelerometer_data_to_duckdb). - Materialize it — runs
write_data_duckdb.Rin summarize mode. - Open asset
movement_intensity_plot(depends onmovement_intensity). - Materialize it — runs
plot_movement_intensity.Rand writesdata/movement_intensity.png. - Explain the Python → subprocess →
Rscriptbridge inr_runner.py.
- In Dagster UI, open asset
weather_api_demo. - Click Materialize.
- Show metadata and output file:
data/weather_open_meteo.csv.
- Open sensor
ingest_csv_sensorin Dagster UI. - Enable the sensor (default status is STOPPED).
- Drop a new CSV file into
data/Ingest/and observe the sensor triggeraccelerometer_ingest_jobautomatically.
- Open schedule
weather_refresh_schedulein Dagster UI. - Enable the schedule (runs
weather_refresh_jobevery minute). - Trigger a manual tick in the UI for immediate demonstration.
You can run any R script through Python directly:
# Ingest CSVs into DuckDB
uv run python run_r_subprocess.py scripts/write_data_duckdb.R data/Ingest data/accelerometer.duckdb all
# Summarize into movement_intensity table
uv run python run_r_subprocess.py scripts/write_data_duckdb.R data/Ingest data/accelerometer.duckdb summarize
# Generate movement intensity plot
uv run python run_r_subprocess.py scripts/plot_movement_intensity.R data/accelerometer.duckdb data/movement_intensity.pngLocal render:
quarto renderOpen:
docs/slides/workshop.html
The workflow .github/workflows/publish-quarto.yml will:
- Render Quarto files on pushes to
main - Publish
docs/togh-pages
After first push, enable GitHub Pages in repository settings:
- Source:
Deploy from a branch - Branch:
gh-pages(root)
- 10 min: Orchestration foundations and Dagster concepts
- 15 min: Ingest accelerometer CSVs to DuckDB
- 10 min: Movement-intensity summary and plot
- 10 min: Sensor-driven pipeline automation
- 10 min: Scheduled weather API refresh
- 5 min: Q&A
Use this checklist to go from clone to first successful Dagster run.
- Open PowerShell in the repository root.
- Verify Python is available:
python --version- Install UV (skip if already installed):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"- Create and activate the virtual environment:
uv venv
.\.venv\Scripts\Activate.ps1- Install project dependencies (including Dagster):
uv sync- Verify Dagster is installed:
uv run dagster --version- Verify R and required packages:
Rscript --version
Rscript -e "if (!requireNamespace('duckdb', quietly=TRUE)) install.packages('duckdb', repos='https://cloud.r-project.org')"
Rscript -e "if (!requireNamespace('DBI', quietly=TRUE)) install.packages('DBI', repos='https://cloud.r-project.org')"If Rscript is not recognized, add your R x64 bin folder to PATH (example):
$target = 'C:\Program Files\R\R-4.5.2\bin\x64'
$env:Path = "$target;$env:Path"
[Environment]::SetEnvironmentVariable('Path', "$target;" + [Environment]::GetEnvironmentVariable('Path','User'), 'User')Then open a new terminal and re-run Rscript --version.
- Start Dagster:
uv run dagster dev -m dagster_livestock_workshop.definitions- Copy accelerometer CSV files into
data/Ingest/and materializeaccelerometer_data_to_duckdb. - Materialize
movement_intensityand thenmovement_intensity_plotand confirmdata/movement_intensity.pngexists.