Compare commits
No commits in common. "v2" and "main" have entirely different histories.
101
main.rs
101
main.rs
@ -1,101 +0,0 @@
|
|||||||
use fathom_function::tracing;
|
|
||||||
use pipeline_application::{
|
|
||||||
application::{Application, MatchingCriteria, SurfaceLocationCriteria as SLC},
|
|
||||||
serialization::{
|
|
||||||
serialize_meter, serialize_millimeter, serialize_orientation_min, serialize_percent,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use uom::si::f64::{Angle, Length, Ratio};
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
#[fathom_function::function]
|
|
||||||
async fn ili_comparison(input: Input) -> Result<Output, String> {
|
|
||||||
let app = Application::new_from_compile_env(input.org_id, input.project_id).unwrap();
|
|
||||||
|
|
||||||
for ((previous_id, newer_id), pipeline_id) in input
|
|
||||||
.older_ili_id
|
|
||||||
.into_iter()
|
|
||||||
.zip(input.newer_ili_id)
|
|
||||||
.zip(input.pipeline_id)
|
|
||||||
{
|
|
||||||
app.ili_comparison(pipeline_id, previous_id, newer_id, &input.criteria)
|
|
||||||
.await
|
|
||||||
.map_err(|err| {
|
|
||||||
tracing::error!(
|
|
||||||
%pipeline_id, %newer_id, %previous_id, ?err,
|
|
||||||
"Error running comparison algorithm"
|
|
||||||
);
|
|
||||||
format!("{err:?}")
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Output {
|
|
||||||
status: "Success".to_owned(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
|
||||||
struct Output {
|
|
||||||
status: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
|
||||||
struct Input {
|
|
||||||
org_id: Uuid,
|
|
||||||
project_id: String,
|
|
||||||
pipeline_id: Vec<Uuid>,
|
|
||||||
older_ili_id: Vec<Uuid>,
|
|
||||||
newer_ili_id: Vec<Uuid>,
|
|
||||||
|
|
||||||
#[serde(flatten)]
|
|
||||||
criteria: Criteria,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
|
||||||
struct Criteria {
|
|
||||||
#[serde(with = "serialize_meter")]
|
|
||||||
weld_location_threshold: Length,
|
|
||||||
#[serde(with = "serialize_meter")]
|
|
||||||
feature_location_threshold: Length,
|
|
||||||
#[serde(with = "serialize_meter")]
|
|
||||||
upstream_girth_threshold: Length,
|
|
||||||
#[serde(with = "serialize_orientation_min")]
|
|
||||||
orientation_threshold: Angle,
|
|
||||||
#[serde(with = "serialize_percent")]
|
|
||||||
minimum_depth_growth_threshold: Ratio,
|
|
||||||
#[serde(with = "serialize_millimeter")]
|
|
||||||
minimum_length_growth_threshold: Length,
|
|
||||||
surface_location_criteria: SurfaceLocationCriteria,
|
|
||||||
#[serde(with = "serialize_percent")]
|
|
||||||
target_minimum_match_rate: Ratio,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, serde::Deserialize)]
|
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
enum SurfaceLocationCriteria {
|
|
||||||
Matching,
|
|
||||||
Any,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<SurfaceLocationCriteria> for SLC {
|
|
||||||
fn from(value: SurfaceLocationCriteria) -> Self {
|
|
||||||
match value {
|
|
||||||
SurfaceLocationCriteria::Matching => Self::Matching,
|
|
||||||
SurfaceLocationCriteria::Any => Self::Any,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&Criteria> for MatchingCriteria {
|
|
||||||
fn from(value: &Criteria) -> Self {
|
|
||||||
MatchingCriteria::default()
|
|
||||||
.with_weld_location_threshold(value.weld_location_threshold)
|
|
||||||
.with_feature_location_threshold(value.feature_location_threshold)
|
|
||||||
.with_upstream_girth_threshold(value.upstream_girth_threshold)
|
|
||||||
.with_orientation_threshold(value.orientation_threshold)
|
|
||||||
.with_minimum_depth_growth_threshold(value.minimum_depth_growth_threshold)
|
|
||||||
.with_minimum_length_growth_threshold(value.minimum_length_growth_threshold)
|
|
||||||
.with_surface_location_criteria(value.surface_location_criteria)
|
|
||||||
.with_target_minimum_match_rate(value.target_minimum_match_rate)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
functions-framework==1.4.3
|
|
||||||
markupsafe==2.0.1
|
|
||||||
Loading…
Reference in New Issue
Block a user