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

[pipes] - Move asset check severity into jsonschema definition #60

Merged
merged 4 commits into from
Dec 19, 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
1 change: 1 addition & 0 deletions libraries/pipes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ jsonschema_rust:
quicktype -s schema -l rust \
--visibility public --derive-debug --derive-clone --derive-partial-eq -o \
implementations/rust/src/types.rs
cd implementations/rust && cargo fmt

jsonschema: jsonschema_rust
1 change: 1 addition & 0 deletions libraries/pipes/implementations/rust/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- (pull/60) Added `AssetCheckSeverity` to the jsonschema definitions
- (pull/59) Moved dagster pipes version into a constant
- (pull/57) Simplify user-facing API for hashmap metadata
- (pull/54) Handled errors for `MessageWriter` implementations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dagster_pipes_rust::types::{PipesMetadataValue, RawValue, Type};
use dagster_pipes_rust::{open_dagster_pipes, AssetCheckSeverity, DagsterPipesError};
use dagster_pipes_rust::types::{AssetCheckSeverity, PipesMetadataValue, RawValue, Type};
use dagster_pipes_rust::{open_dagster_pipes, DagsterPipesError};

use std::collections::HashMap;

Expand Down
12 changes: 3 additions & 9 deletions libraries/pipes/implementations/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod writer;

use std::collections::HashMap;

use serde::Serialize;
use serde_json::json;
use serde_json::Map;
use serde_json::Value;
Expand All @@ -18,7 +17,9 @@ use crate::context_loader::PayloadErrorKind;
use crate::params_loader::EnvVarLoader as PipesEnvVarParamsLoader;
pub use crate::params_loader::LoadParams;
use crate::params_loader::ParamsError;
pub use crate::types::{Method, PipesContextData, PipesMessage, PipesMetadataValue};
pub use crate::types::{
AssetCheckSeverity, Method, PipesContextData, PipesMessage, PipesMetadataValue,
};
use crate::writer::message_writer::get_opened_payload;
use crate::writer::message_writer::DefaultWriter as PipesDefaultMessageWriter;
pub use crate::writer::message_writer::{DefaultWriter, MessageWriter};
Expand All @@ -27,13 +28,6 @@ use crate::writer::message_writer_channel::{MessageWriteError, MessageWriterChan

const DAGSTER_PIPES_VERSION: &str = "0.1";

#[derive(Serialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum AssetCheckSeverity {
Warn,
Error,
}

impl PipesMetadataValue {
pub fn new(raw_value: types::RawValue, pipes_metadata_value_type: types::Type) -> Self {
Self {
Expand Down
13 changes: 11 additions & 2 deletions libraries/pipes/implementations/rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
// extern crate serde_derive;
// extern crate serde_json;
//
// use generated_module::PipesContextData;
// use generated_module::AssetCheckSeverity;
//
// fn main() {
// let json = r#"{"answer": 42}"#;
// let model: PipesContextData = serde_json::from_str(&json).unwrap();
// let model: AssetCheckSeverity = serde_json::from_str(&json).unwrap();
// }

use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum AssetCheckSeverity {
#[serde(rename = "ERROR")]
Error,

#[serde(rename = "WARN")]
Warn,
}

/// The serializable data passed from the orchestration process to the external process. This
/// gets wrapped in a PipesContext.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
6 changes: 6 additions & 0 deletions libraries/pipes/jsonschema/AssetCheckSeverity.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "AssetCheckSeverity",
"type": "string",
"enum": ["WARN", "ERROR"],
"additionalProperties": false
}
Loading