Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Add a python integration test for a rust subprocess job #23

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ __pycache__/
*.py[cod]
*$py.class
*.egg-info/

.vscode
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import shutil

from dagster import (
asset,
AssetCheckSpec,
AssetExecutionContext,
file_relative_path,
materialize_to_memory,
MaterializeResult,
PipesSubprocessClient,
PipesEnvContextInjector,
)


def test_example_rust_subprocess_asset():
@asset(
check_specs=[
AssetCheckSpec(
name="example_rust_subprocess_check",
asset="example_rust_subprocess_asset",
)
],
)
def example_rust_subprocess_asset(
context: AssetExecutionContext, pipes_subprocess_client: PipesSubprocessClient
) -> MaterializeResult:
"""Demonstrates running Rust binary in a subprocess."""
cmd = [shutil.which("cargo"), "run"]
cwd = file_relative_path(__file__, "../rust_processing_jobs")
return pipes_subprocess_client.run(
command=cmd,
cwd=cwd,
context=context,
).get_materialize_result()

result = materialize_to_memory(
assets=[example_rust_subprocess_asset],
resources={
"pipes_subprocess_client": PipesSubprocessClient(
context_injector=PipesEnvContextInjector(),
)
},
)
assert result.success
assert result.get_asset_materialization_events()[0].asset_key.path == [
"example_rust_subprocess_asset"
]
assert (
result.get_asset_check_evaluations()[0].asset_check_key.name
== "example_rust_subprocess_check"
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> Result<(), DagsterPipesError> {
"example_rust_subprocess_check",
true,
"example_rust_subprocess_asset",
AssetCheckSeverity::Warn,
&AssetCheckSeverity::Warn,
json!({"quality": {"raw_value": 5, "type": "int"}}),
);
Ok(())
Expand Down
Loading