Automatic push from FunctionsAPI
This commit is contained in:
parent
1c64a64787
commit
66fa3ff534
3557
Cargo.lock
generated
Normal file
3557
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "web"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
axum = { version = "0.8", features = ["macros"] }
|
||||||
|
fathom-function = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
pipeline-application = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
pipeline-configuration = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/ili-comparison" }
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
uom = { version = "0.36" }
|
||||||
|
uuid = { version = "1" }
|
||||||
82
README.md
82
README.md
@ -1,2 +1,82 @@
|
|||||||
# 4c8e5c58a9bf4c55a5ead00269a87d54
|
# Dynamic segmentation function
|
||||||
|
|
||||||
|
The ILI Comparison module is a valuable tool designed to compare anomalies found in two
|
||||||
|
separate ILIs of the same pipeline. This module operates on an intelligent method that
|
||||||
|
incorporates user-defined criteria to ensure precision in the comparison process. The workflow
|
||||||
|
of this module begins with a girth-weld alignment step, which is crucial for identifying and
|
||||||
|
aligning the correct girth welds from the two in-line inspection reports. In this case, the
|
||||||
|
girth-weld alignment is applied to ILI reports conducted on 2011-06-01 and 2015-12-21, ensuring
|
||||||
|
accurate alignment between the inspections. Both ILIs were performed by Rosen using the MFL
|
||||||
|
(Magnetic Flux Leakage) technology.
|
||||||
|
|
||||||
|
Subsequently, the module matches metal loss corrosion anomalies based on the user's specified
|
||||||
|
criteria. This matching process evaluates the evolution of anomalies over a 5.5-year interval,
|
||||||
|
the time gap between the two ILIs. The output includes detailed reports that categorize the
|
||||||
|
results into matched features, matched anomalies, unmatched features, and unmatched anomalies.
|
||||||
|
In its final output, the module generates a comprehensive KPI Dashboard that showcases the
|
||||||
|
percentage of matched anomalies, providing users with an overview of the comparison results.
|
||||||
|
Furthermore, six charts visually illustrate the growth of matched anomalies over the 5.5-year
|
||||||
|
time interval between the two inspections. These visualizations provide valuable insights into
|
||||||
|
how anomalies have evolved and help users track changes in pipeline integrity over time.
|
||||||
|
|
||||||
|
In addition, the validated results from this module are used in the Local Growth Rate Module
|
||||||
|
for calculating the Final ACR and conducting future integrity assessments. The ILI Comparison
|
||||||
|
module, through the integration of historical and recent inspection data, offers an essential
|
||||||
|
framework for monitoring pipeline conditions and supporting maintenance decisions.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
### Arguments
|
||||||
|
|
||||||
|
- `org_id`: as string which should be a valid `uuid` for the organization
|
||||||
|
- `project_id`: the id of the data project where the pipeline data is found
|
||||||
|
- `older_ili_id`: a `array` of string values representing a valid `uuid` for an ili report sequence
|
||||||
|
- `newer_ili_id`: a `array` of string values representing a valid `uuid` for an ili report sequence
|
||||||
|
- `weld_location_threshold`: a `float` value
|
||||||
|
- `facility_location_threshold`: a `float` value
|
||||||
|
- `upstream_girth_threshold`: a `float` value
|
||||||
|
- `orientation_threshold`: a `float` value
|
||||||
|
- `minimal_depth_growth_threshold`: a `float` value
|
||||||
|
- `minimal_length_growth_threshold`: a `float` value
|
||||||
|
- `surface_location_matching_criteria`: an array of `string` each valve should be one of
|
||||||
|
- `matching`
|
||||||
|
- `any`
|
||||||
|
- `target_minimum_match_rate`: a `float` value
|
||||||
|
|
||||||
|
## Creating the function on the platform
|
||||||
|
|
||||||
|
To create this function on the platform using the `cli` set up the port forwarding as shown in README.
|
||||||
|
|
||||||
|
Then run the following command to create the function.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run functions create \
|
||||||
|
-f functions/ili_comparison \
|
||||||
|
-d "Compare two ILI reports" \
|
||||||
|
-i org_id=string \
|
||||||
|
-i project_id=string \
|
||||||
|
-i older_ili_id=array \
|
||||||
|
-i newer_ili_id=array \
|
||||||
|
-i weld_location_threshold=float \
|
||||||
|
-i upstream_girth_threshold=float \
|
||||||
|
-i orientation_threshold=float \
|
||||||
|
-i minimal_depth_growth_threshold=float \
|
||||||
|
-i minimal_length_growth_threshold=float \
|
||||||
|
-i surface_location_matching_criteria=string \
|
||||||
|
-i target_minimum_match_rate=float
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing the function locally
|
||||||
|
|
||||||
|
You can run and test the function locally by running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can check it work with `curl` as follows
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST localhost:8080 -v \
|
||||||
|
-d "\"{\\\"facilities\\\": [\\\"repair\\\"], \\\"formData\\\": {\\\"facilities\\\": [\\\"repairs\\\"], \\\"localProperties\\\": [\\\"material_grade\\\", \\\"coating_type\\\", \\\"soil_type\\\", \\\"soil_ph\\\"]}, \\\"input\\\": null, \\\"local_data\\\": [\\\"material_grade\\\", \\\"coating_type\\\", \\\"soil_type\\\", \\\"soil_ph\\\"]}\""
|
||||||
|
```
|
||||||
|
|||||||
90
src/main.rs
Normal file
90
src/main.rs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
use pipeline_application::application::{
|
||||||
|
Application, Env, MatchingCriteria, SurfaceLocationCriteria as SLC,
|
||||||
|
};
|
||||||
|
use pipeline_configuration::serialization::{
|
||||||
|
serialize_meter, serialize_millimeter, serialize_orientation_min, serialize_percent,
|
||||||
|
};
|
||||||
|
use uom::si::f64::{Angle, Length, Ratio};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
// There is an issue with the data form component at the moment and its giving back
|
||||||
|
// a null value
|
||||||
|
const DEFAULT_PROJECT_ID: &str = "680b61b0aedd6f9e639d8699";
|
||||||
|
|
||||||
|
#[fathom_function::function]
|
||||||
|
async fn ili_comparison(input: Input) -> Result<String, String> {
|
||||||
|
let app = Application::new(
|
||||||
|
Env::Dev,
|
||||||
|
input.org_id,
|
||||||
|
input.project_id.as_deref().unwrap_or(DEFAULT_PROJECT_ID),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for (previous_id, newer_id) in input.older_ili_id.into_iter().zip(input.newer_ili_id) {
|
||||||
|
app.ili_comparison(previous_id, newer_id, &input.criteria)
|
||||||
|
.await
|
||||||
|
.map_err(|err| err.to_string())?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok("Success".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
struct Input {
|
||||||
|
org_id: Uuid,
|
||||||
|
project_id: Option<String>,
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user