Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dagster-pipes-rust] - Inital integration with the pipes test suite #66

Merged
merged 9 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/libraries-pipes-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ jobs:
with:
tool: nextest

- name: "Install uv"
uses: astral-sh/setup-uv@v4

- name: "Tests"
run: cargo nextest run

- name: "Doctests"
run: cargo test --doc

- name: "Python tests"
marijncv marked this conversation as resolved.
Show resolved Hide resolved
run: uv run pytest

integration:
name: "integration"
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions libraries/pipes/implementations/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ serde_json = "1"
base64 = "0"
flate2 = "1"
thiserror = "2.0.3"
clap = { version = "4.5.23", features = ["derive"], optional = true}

[dev-dependencies]
rstest = { version = "0.23.0", default-features = false }
tempfile = "3.14.0"

[workspace]
members = ["example-dagster-pipes-rust-project/rust_processing_jobs"]

[features]
pipes-tests = ["dep:clap"]

[[bin]]
name = "pipes_tests"
required-features = ["pipes-tests"]
13 changes: 13 additions & 0 deletions libraries/pipes/implementations/rust/pipes.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[general]
error_reporting = false

[messages]
log = false
report_custom_message = false
report_asset_materialization = false
report_asset_check = false
log_external_stream = false

[message_channel]
s3 = false
databricks = false
26 changes: 26 additions & 0 deletions libraries/pipes/implementations/rust/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "dagster-pipes-rust"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"dagster>=1.8.9",
]

[tool.uv]
dev-dependencies = [
"dagster-webserver>=1.8.9",
"pyright>=1.1.383",
"pytest>=8.3.3",
"ruff>=0.6.8",
"dagster-pipes-tests",
]

[tool.uv.sources]
dagster-pipes-tests = { path = "../../tests/dagster-pipes-tests", editable = true }

[tool.pytest.ini_options]
addopts = "-s "
color = "yes"
testpaths = ["tests"]
88 changes: 88 additions & 0 deletions libraries/pipes/implementations/rust/src/bin/pipes_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
use clap::ArgAction;
use clap::Parser;
use dagster_pipes_rust::{open_dagster_pipes, DagsterPipesError};
use dagster_pipes_rust::{DAGSTER_PIPES_CONTEXT_ENV_VAR, DAGSTER_PIPES_MESSAGES_ENV_VAR};
use std::collections::HashMap;
use std::fs::File;

#[derive(Parser)]
struct Cli {
#[arg(long)]
context: Option<String>,
#[arg(long)]
messages: Option<String>,
#[arg(
long,
action = ArgAction::Set,
default_value_t = false,
default_missing_value = "false",
num_args=0..=1,
require_equals = false,
)]
env: bool,
#[arg(long = "jobName")]
job_name: Option<String>,
#[arg(long)]
extras: Option<String>,
#[arg(
long,
action = ArgAction::Set,
default_value_t = false,
default_missing_value = "false",
num_args=0..=1,
require_equals = false,
)]
full: bool,
#[arg(long)]
custom_payload_path: Option<String>,
#[arg(long)]
report_asset_check: Option<String>,
#[arg(long)]
report_asset_materialization: Option<String>,
#[arg(
long,
action = ArgAction::Set,
default_value_t = false,
default_missing_value = "false",
num_args=0..=1,
require_equals = false,
)]
throw_error: bool,
#[arg(
long,
action = ArgAction::Set,
default_value_t = false,
default_missing_value = "false",
num_args=0..=1,
require_equals = false,
)]
logging: bool,
#[arg(long)]
message_writer: Option<String>,
#[arg(long)]
context_loader: Option<String>,
}

pub fn main() -> Result<(), DagsterPipesError> {
let args = Cli::parse();
if let Some(context) = args.context {
std::env::set_var(DAGSTER_PIPES_CONTEXT_ENV_VAR, &context);
}
if let Some(messages) = args.messages {
std::env::set_var(DAGSTER_PIPES_MESSAGES_ENV_VAR, &messages);
}

let context = open_dagster_pipes()?;

if let Some(job_name) = args.job_name {
assert_eq!(context.data.job_name, Some(job_name));
}

if let Some(extras) = args.extras {
let file = File::open(extras).expect("extras could not be opened");
let json: HashMap<std::string::String, std::option::Option<serde_json::Value>> =
serde_json::from_reader(file).expect("extras could not be parsed");
assert_eq!(context.data.extras, Some(json));
}
Ok(())
}
6 changes: 4 additions & 2 deletions libraries/pipes/implementations/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ use crate::writer::message_writer::{
use crate::writer::message_writer_channel::MessageWriteError;

pub use crate::context_loader::LoadContext;
pub use crate::params_loader::LoadParams;
pub use crate::params_loader::{
LoadParams, DAGSTER_PIPES_CONTEXT_ENV_VAR, DAGSTER_PIPES_MESSAGES_ENV_VAR,
};
pub use crate::types::{AssetCheckSeverity, PipesMetadataValue};
pub use crate::writer::message_writer::{DefaultWriter, MessageWriter};
pub use crate::writer::message_writer_channel::MessageWriterChannel;
Expand All @@ -34,7 +36,7 @@ pub struct PipesContext<W>
where
W: MessageWriter,
{
data: PipesContextData,
pub data: PipesContextData,
message_channel: W::Channel,
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/pipes/implementations/rust/src/params_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::fmt;
use std::io::Read;
use thiserror::Error;

const DAGSTER_PIPES_CONTEXT_ENV_VAR: &str = "DAGSTER_PIPES_CONTEXT";
const DAGSTER_PIPES_MESSAGES_ENV_VAR: &str = "DAGSTER_PIPES_MESSAGES";
pub const DAGSTER_PIPES_CONTEXT_ENV_VAR: &str = "DAGSTER_PIPES_CONTEXT";
pub const DAGSTER_PIPES_MESSAGES_ENV_VAR: &str = "DAGSTER_PIPES_MESSAGES";

/// Load params passed from the orchestration process by the context injector and
/// message reader. These params are used to respectively bootstrap implementations of
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions libraries/pipes/implementations/rust/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest
import subprocess


@pytest.fixture(scope="session", autouse=True)
def built_binary():
subprocess.run(["cargo", "build", "--features", "pipes-tests"], check=True)
6 changes: 6 additions & 0 deletions libraries/pipes/implementations/rust/tests/test_pipes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from dagster_pipes_tests import PipesTestSuite


class TestRustPipes(PipesTestSuite):
BASE_ARGS = ["./target/debug/pipes_tests"]

Loading
Loading