Compare commits

..

No commits in common. "v8" and "main" have entirely different histories.
v8 ... main

4 changed files with 1 additions and 3710 deletions

3535
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
[package]
edition = "2024"
name = "web"
version = "0.1.0"
[dependencies]
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"] }

112
README.md
View File

@ -1,112 +1,2 @@
# Dynamic segmentation function
# affa088da0d84cafa9d74f2c79dd0eda
A function that exposes the dynamic segmentation algorithm for the pipeline use
case.
This function will recompute the segmentation for all pipelines based on the
provided segmentation configuration
Segmentation is the process of taking local data, crossings, and facilities on
the pipeline and creating pipeline segments where this local data changes (a
cut line).
In fathom we support dynamic segmentation where the user is able to configure
the properties they would like to consider when segmentizing and to support
re-segmentizing the pipeline at any point such as when new data is available
from an ILI report.
Segmentation can be dynamically configured to consider the following properties
- pipeline diameter (currently required)
- wall thickness (currently required)
- material grade
- coating type
- design factor
- high consequence area
- unusual sensitive area
- join type
- soil type
- soil ph
Additionally the following crossing types can be considered
- Road
- River
- Railroad
- Overhead
- Highway
- Pipeline
Finally, the following facilities can also be used to create cut lines
- Valves
- Insulation joints
- Repairs
The user is able to configure which the the local properties and which of the
crossing and facility types they would like to consider for creating the
segmentation. For the purpose of the analytics required later in the process we
require the user segments on diameter and wall thickness. The other properties
are optional.
## Example
```none
diameter ├──────────────────────────┼────────────────────────────────────┤
40 inch 42 inch
wall thickness ├───────┼─────────────────────────────────────────────────┼─────┤
12.0 9.0 12.0
material grade ├──────────────────────────┼──────────────────────────────┼─────┤
L290 L320
design factor ├─────────────────────────────────────────────────────────┼─────┤
L72
road crossing ├──┤ ├──┤
river crossing ├──┤ ├──┤
valve │ │
repair ├─┤
segments ├─┼──┼──┼──────────┼──┼────┼────┼─┼──────────┼──┼──┼──┼───┼──┼──┤
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
```
## Input
### Arguments
- `facilities`: an array of `string` each valve should be one of
- `insulation_joint`
- `repair`
- `valve`.
- `crossings`: TODO
- `local_data`: an array of `string` each value should be one of
- `material_grade`
- `coating_type`
- `design_factor`
- `high_consequence_area`
- `unusual_sensitive_area`
- `joint_type`
- `soil_type`
- `soil_ph`
### Environment
- `ORG_ID`: the organization id
- `PROJECT_ID`: the id of the data project where the pipeline data is found
- `ENV`: the environment of the platform e.g. `dev` or `stg` etc.
## 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\\\"]}\""
```

View File

@ -1,53 +0,0 @@
use fathom_function::Context;
use pipeline_application::application::{Application, SegmentationConfiguration};
use pipeline_configuration::facilities::FacilityType;
#[fathom_function::function(default(
org_id = "2cbfe270-d195-48ad-aed1-24145924635c",
project_id = "6807aed617c4295ab4a6aa78"
))]
async fn segment(context: Context, args: Args) -> Result<String, String> {
Application::new(context.env, context.org_id, context.project_id)
.unwrap()
.segment_all(args)
.await
.map_err(|err| err.to_string())?;
Ok("Success".to_string())
}
#[derive(Debug, serde::Deserialize)]
struct Args {
facilities: Vec<FacilityType>,
local_data: Vec<String>,
}
impl From<Args> for SegmentationConfiguration {
fn from(value: Args) -> Self {
let mut config = Self::default_false();
for fac in value.facilities {
config = match fac {
FacilityType::InsulationJoint => config.by_insulation_joints(true),
FacilityType::Repair => config.by_repairs(true),
FacilityType::Valve => config.by_valves(true),
_ => config,
};
}
// TODO: add crossing configuration
for loc in value.local_data {
config = match loc.as_str() {
"material_grade" => config.by_material_grade(true),
"coating_type" => config.by_coating_type(true),
"design_factor" => config.by_design_factor(true),
"high_consequence_area" => config.by_high_consequence_area(true),
"unusual_sensitive_area" => config.by_unusual_sensitive_area(true),
"joint_type" => config.by_joint_type(true),
"soil_type" => config.by_soil_type(true),
"soil_ph" => config.by_soil_ph(true),
_ => config,
}
}
config
}
}