Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2a344674e |
3347
Cargo.lock
generated
Normal file
3347
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2024"
|
||||||
|
name = "web"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
chrono = { version = "0.4" }
|
||||||
|
# fathom-function = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/pipeline-route" }
|
||||||
|
# pipeline-application = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/pipeline-route" }
|
||||||
|
# pipeline-configuration = { git = "ssh://git@github.com/fathom-io/pipeline-calculations.git", branch = "johnabell/pipeline-route" }
|
||||||
|
fathom-function = { path = "../../fathom-function" }
|
||||||
|
pipeline-application = { path = "../../pipeline-application" }
|
||||||
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
uuid = { version = "1" }
|
||||||
70
README.md
70
README.md
@ -1,2 +1,70 @@
|
|||||||
# 48d176606dcd443499509d7da6dd90b6
|
# Creation of an ILI report
|
||||||
|
|
||||||
|
A function that will create a ILI report asset and sequence.
|
||||||
|
|
||||||
|
## Input
|
||||||
|
|
||||||
|
### Arguments
|
||||||
|
|
||||||
|
- `pipeline_id`: a `string` which should be a valid uuid for a pipeline.
|
||||||
|
- `date`: a `string` formatted as an ISO date representing the date of the
|
||||||
|
inspection.
|
||||||
|
- `vendor_name`: a `string` the company who conducted the ILI inspection
|
||||||
|
- `report_type`: a `string` the type of the report possible values:
|
||||||
|
- `final`
|
||||||
|
- `preliminary`
|
||||||
|
- `inspection_type`: a `string` the type of technology used possible values:
|
||||||
|
- `mfl`
|
||||||
|
- `tfi`
|
||||||
|
- `ut`
|
||||||
|
- `emat`
|
||||||
|
- `caliper`
|
||||||
|
- `combo_mfl_and_tfi`
|
||||||
|
- `combo_mfl_and_ut`
|
||||||
|
- `combo_mfl_and_ec`
|
||||||
|
- `file_details`: a `object` representing uploaded report file.
|
||||||
|
- `pipebody_tolerances`: an `object` representing the tolerances for the pipebody
|
||||||
|
- `haz_tolerances`: an `object` representing the tolerances for the heat affected zone (HAZ)
|
||||||
|
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
|
||||||
|
## 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_creation \
|
||||||
|
-n uploadili \
|
||||||
|
-d "Processes an ILI file and create the sequences and assets associated with that report" \
|
||||||
|
-i pipeline_id=string \
|
||||||
|
-i date=string \
|
||||||
|
-i vendor_name=string \
|
||||||
|
-i report_type=string \
|
||||||
|
-i inspection_type=string \
|
||||||
|
-i file_details=object \
|
||||||
|
-i pipebody_tolerances=object \
|
||||||
|
-i haz_tolerances=object
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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 "\"{\\\"pipeline_id\\\": \\\"0195a527-f16b-7d83-b936-35bc2dd92f9d\\\"}\""
|
||||||
|
```
|
||||||
|
|||||||
53
src/main.rs
Normal file
53
src/main.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
use chrono::NaiveDate;
|
||||||
|
use fathom_function::Context;
|
||||||
|
use pipeline_application::application::{
|
||||||
|
Application, InlineInspection, InspectionType, ReportType, ToolTolerances,
|
||||||
|
};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[fathom_function::function(default(
|
||||||
|
org_id = "2cbfe270-d195-48ad-aed1-24145924635c",
|
||||||
|
project_id = "67c6f36910e4c56ed42bf841"
|
||||||
|
))]
|
||||||
|
async fn pipeline_route(context: Context, input: Input) -> Result<String, String> {
|
||||||
|
Application::new(context.env, context.org_id, &context.project_id)
|
||||||
|
.unwrap()
|
||||||
|
.process_ili_report(
|
||||||
|
uuid::uuid!("0195a527-f16b-7d83-b936-35bc2dd92f9d"),
|
||||||
|
input.file_details.id,
|
||||||
|
ToolTolerances::default(),
|
||||||
|
input,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
Ok("Success".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct Input {
|
||||||
|
pipeline_id: Uuid,
|
||||||
|
date: NaiveDate,
|
||||||
|
vendor_name: String,
|
||||||
|
report_type: ReportType,
|
||||||
|
/// The inspection type and technology used.
|
||||||
|
inspection_type: InspectionType,
|
||||||
|
file_details: FileDetails,
|
||||||
|
// TODO: parse the output of the tool tolerances.
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Input> for InlineInspection {
|
||||||
|
fn from(value: Input) -> Self {
|
||||||
|
Self {
|
||||||
|
date: value.date,
|
||||||
|
vendor_name: value.vendor_name,
|
||||||
|
report_type: value.report_type,
|
||||||
|
inspection_type: value.inspection_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct FileDetails {
|
||||||
|
id: Uuid,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user