quick-pp 0.2.3__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {quick_pp-0.2.3 → quick_pp-0.2.5}/.gitignore +8 -4
- {quick_pp-0.2.3 → quick_pp-0.2.5}/PKG-INFO +43 -27
- {quick_pp-0.2.3 → quick_pp-0.2.5}/README.md +41 -23
- {quick_pp-0.2.3 → quick_pp-0.2.5}/pyproject.toml +2 -4
- quick_pp-0.2.3/quick_pp/logger.py → quick_pp-0.2.5/quick_pp/__init__.py +4 -0
- quick_pp-0.2.5/quick_pp/api/main.py +129 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/mlflow_model_deployment.py +6 -3
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/router.py +2 -1
- quick_pp-0.2.5/quick_pp/api/services/chat.py +92 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/lithology.py +4 -4
- quick_pp-0.2.5/quick_pp/api/template/chat.html +322 -0
- quick_pp-0.2.5/quick_pp/api/template/home.html +74 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/cli.py +14 -12
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/config.py +69 -17
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/core_calibration.py +1 -1
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/fluid_type.py +53 -2
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/las_handler.py +8 -4
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/lithology/__init__.py +16 -3
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/lithology/carbonate.py +56 -6
- quick_pp-0.2.5/quick_pp/lithology/multi_mineral.py +457 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/lithology/sand_shale.py +28 -7
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/lithology/sand_silt_clay.py +29 -11
- quick_pp-0.2.5/quick_pp/lithology/thin_beds.py +273 -0
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/machine_learning}/config.py +9 -9
- quick_pp-0.2.5/quick_pp/machine_learning/feature_engineering.py +134 -0
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/machine_learning}/predict_pipeline.py +52 -8
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/machine_learning}/train_pipeline.py +21 -23
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/machine_learning}/utils.py +2 -2
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/objects.py +38 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/permeability.py +49 -13
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/plotter/plotter.py +2 -2
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/plotter/well_log.py +88 -26
- quick_pp-0.2.5/quick_pp/plotter/well_log_config.py +465 -0
- quick_pp-0.2.5/quick_pp/plotter/xplots.py +170 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/porosity.py +89 -19
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/qaqc.py +110 -105
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/ressum.py +176 -7
- quick_pp-0.2.5/quick_pp/rock_physics/geomechanics.py +558 -0
- quick_pp-0.2.5/quick_pp/rock_physics/geophysics.py +543 -0
- quick_pp-0.2.5/quick_pp/rock_physics/rpm.py +323 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/rock_type.py +45 -17
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/saturation.py +168 -41
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/utils.py +160 -76
- quick_pp-0.2.3/quick_pp/api/main.py +0 -90
- quick_pp-0.2.3/quick_pp/api/qpp_assistant.py +0 -160
- quick_pp-0.2.3/quick_pp/geomechanics.py +0 -195
- quick_pp-0.2.3/quick_pp/lithology/multi_mineral.py +0 -151
- quick_pp-0.2.3/quick_pp/plotter/well_log_config.py +0 -409
- {quick_pp-0.2.3 → quick_pp-0.2.5}/AUTHORS.rst +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/LICENSE +0 -0
- {quick_pp-0.2.3/quick_pp → quick_pp-0.2.5/quick_pp/api}/__init__.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.3 → quick_pp-0.2.5}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.3/quick_pp/api → quick_pp-0.2.5/quick_pp/machine_learning}/__init__.py +0 -0
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/machine_learning}/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.3/quick_pp/modelling → quick_pp-0.2.5/quick_pp/plotter}/__init__.py +0 -0
- {quick_pp-0.2.3/quick_pp/plotter → quick_pp-0.2.5/quick_pp/rock_physics}/__init__.py +0 -0
|
@@ -84,7 +84,7 @@ celerybeat-schedule
|
|
|
84
84
|
.env
|
|
85
85
|
|
|
86
86
|
# virtualenv
|
|
87
|
-
.venv
|
|
87
|
+
.venv**
|
|
88
88
|
venv**
|
|
89
89
|
ENV/
|
|
90
90
|
|
|
@@ -106,14 +106,18 @@ ENV/
|
|
|
106
106
|
.idea/
|
|
107
107
|
|
|
108
108
|
# Folders
|
|
109
|
-
notebooks/outputs
|
|
109
|
+
notebooks/outputs**
|
|
110
|
+
notebooks/data/01_raw/VOLVE/seismic/*
|
|
111
|
+
notebooks/data/01_raw/VOLVE/*.las
|
|
110
112
|
notebooks/data/02_intermediate/*
|
|
111
113
|
notebooks/data/03_processed/*
|
|
112
114
|
notebooks/data/04_project/*
|
|
113
115
|
notebooks/local/*
|
|
114
116
|
notebooks/03_qpp__*
|
|
115
|
-
uploads
|
|
116
|
-
mlruns
|
|
117
|
+
uploads**
|
|
118
|
+
**mlruns**
|
|
117
119
|
data/*
|
|
118
120
|
.chainlit*
|
|
119
121
|
chainlit*
|
|
122
|
+
.files**
|
|
123
|
+
**_info**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quick-pp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
|
|
5
5
|
Project-URL: Homepage, https://github.com/imranfadhil/quick_pp
|
|
6
6
|
Author-email: Imran Fadhil <imranfadhil@gmail.com>
|
|
@@ -14,11 +14,8 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
14
14
|
Classifier: Natural Language :: English
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Requires-Python: >=3.11
|
|
17
|
-
Requires-Dist: chainlit==2.5.5
|
|
18
17
|
Requires-Dist: click>=7.0
|
|
19
18
|
Requires-Dist: fastapi
|
|
20
|
-
Requires-Dist: fastapi-mcp
|
|
21
|
-
Requires-Dist: langchain-ollama==0.3.3
|
|
22
19
|
Requires-Dist: loguru
|
|
23
20
|
Requires-Dist: matplotlib==3.8.0
|
|
24
21
|
Requires-Dist: mlflow
|
|
@@ -26,6 +23,7 @@ Requires-Dist: orjson
|
|
|
26
23
|
Requires-Dist: pandas
|
|
27
24
|
Requires-Dist: psycopg2-binary
|
|
28
25
|
Requires-Dist: ptitprince
|
|
26
|
+
Requires-Dist: python-multipart
|
|
29
27
|
Requires-Dist: ruptures
|
|
30
28
|
Requires-Dist: salib==1.5.1
|
|
31
29
|
Requires-Dist: scikit-learn
|
|
@@ -39,23 +37,27 @@ Python package to assist in providing quick-look/ preliminary petrophysical esti
|
|
|
39
37
|

|
|
40
38
|
|
|
41
39
|
## Quick Start (Jupyter Notebook Examples)
|
|
42
|
-
1. Create virtual environment (tested working with Python3.
|
|
43
|
-
|
|
40
|
+
1. Create virtual environment (tested working with Python3.11)
|
|
41
|
+
|
|
42
|
+
python -m venv venv
|
|
44
43
|
|
|
45
44
|
2. Activate virtual environment
|
|
46
|
-
|
|
45
|
+
|
|
46
|
+
> venv\Scripts\activate (Windows)
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
> source venv/bin/activate (Linux)
|
|
49
49
|
|
|
50
50
|
3. Install requirements
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
pip install -r requirements.txt
|
|
52
53
|
|
|
53
54
|
4. Launch the notebook and run the cells
|
|
54
55
|
- 01_data_handler: create the MOCK qppp project file.
|
|
55
56
|
- 02_EDA: quick look on the data
|
|
56
57
|
- 03_*: quick petropohysical interpretation of the MOCK wells.
|
|
57
58
|
- For API notebook, need to run the following before running the cells
|
|
58
|
-
|
|
59
|
+
|
|
60
|
+
python main.py app
|
|
59
61
|
|
|
60
62
|
## Install
|
|
61
63
|
To install, use the following command:
|
|
@@ -63,41 +65,55 @@ To install, use the following command:
|
|
|
63
65
|
`pip install quick_pp`
|
|
64
66
|
|
|
65
67
|
To use qpp_assistant, you would need to;
|
|
66
|
-
1.
|
|
67
|
-
2. Run `
|
|
68
|
+
1. Run `git clone https://github.com/imranfadhil/quick_pp.git`
|
|
69
|
+
2. Run `pip install -r requirements.txt`
|
|
70
|
+
3. Specify the required credentials in .env (based on `.env copy` file)
|
|
71
|
+
4. Run `docker-compose up -d`
|
|
72
|
+
5. Go to Langflow at http://localhost:7860 and build your flow.
|
|
73
|
+
6. Run `python main.py app` and go to the qpp Assistant at http://localhost:8888/qpp_assistant to test your flow.
|
|
68
74
|
|
|
69
75
|
## CLI
|
|
70
|
-
To start the App
|
|
71
|
-
> quick_pp app
|
|
72
|
-
|
|
73
|
-
You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
|
|
74
|
-
|
|
75
|
-
To use the mcp tools, you would need to first add the following SSE URLS through the interface;
|
|
76
|
-
http://localhost:8888/mcp - quick_pp tools.
|
|
77
|
-
|
|
78
|
-
http://localhost:5555/mcp - quick_pp ML model prediction tools (will only be available after ML models are trained and registered).
|
|
79
76
|
|
|
77
|
+
To train an ML model, these are the requirements;
|
|
80
78
|
|
|
81
|
-
To train an ML model, these are the requirements;
|
|
82
79
|
1. The input file in parquet format need to be available; /data/input/<data_hash>___.parquet
|
|
80
|
+
|
|
83
81
|
2. The parquet file need to have the input and target features as specified in MODELLING_CONFIG in config.py.
|
|
82
|
+
|
|
84
83
|
> quick_pp train <model_config> <data_hash>
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
quick_pp train mock mock
|
|
87
86
|
|
|
88
87
|
To run the MLflow server
|
|
89
|
-
|
|
88
|
+
|
|
89
|
+
quick_pp mlflow-server
|
|
90
|
+
|
|
91
|
+
You can access the mlflow server at http://localhost:5015
|
|
90
92
|
|
|
91
93
|
To run prediction, the trained models need to be registered in MLflow first.
|
|
94
|
+
|
|
92
95
|
> quick_pp predict <model_config> <data_hash>
|
|
93
96
|
|
|
94
|
-
|
|
97
|
+
quick_pp predict mock mock
|
|
95
98
|
|
|
96
|
-
To deploy the trained ML models
|
|
97
|
-
|
|
99
|
+
To deploy the trained ML models
|
|
100
|
+
|
|
101
|
+
quick_pp model-deployment
|
|
98
102
|
|
|
99
103
|
You can access the deployed model Swagger UI at http://localhost:5555/docs
|
|
100
104
|
|
|
105
|
+
To start the App
|
|
106
|
+
|
|
107
|
+
quick_pp app
|
|
108
|
+
|
|
109
|
+
You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
|
|
110
|
+
You can enter any user name and password to login the qpp_assistant.
|
|
111
|
+
|
|
112
|
+
To use the mcp tools, you would need to first add the following SSE URLS through the interface;
|
|
113
|
+
http://localhost:8888/mcp - quick_pp tools.
|
|
114
|
+
|
|
115
|
+
http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
|
|
116
|
+
|
|
101
117
|
## Documentation
|
|
102
118
|
Documentation is available at:
|
|
103
119
|
<https://quick-pp.readthedocs.io/en/latest/index.html>
|
|
@@ -4,23 +4,27 @@ Python package to assist in providing quick-look/ preliminary petrophysical esti
|
|
|
4
4
|

|
|
5
5
|
|
|
6
6
|
## Quick Start (Jupyter Notebook Examples)
|
|
7
|
-
1. Create virtual environment (tested working with Python3.
|
|
8
|
-
|
|
7
|
+
1. Create virtual environment (tested working with Python3.11)
|
|
8
|
+
|
|
9
|
+
python -m venv venv
|
|
9
10
|
|
|
10
11
|
2. Activate virtual environment
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
> venv\Scripts\activate (Windows)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
> source venv/bin/activate (Linux)
|
|
14
16
|
|
|
15
17
|
3. Install requirements
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
pip install -r requirements.txt
|
|
17
20
|
|
|
18
21
|
4. Launch the notebook and run the cells
|
|
19
22
|
- 01_data_handler: create the MOCK qppp project file.
|
|
20
23
|
- 02_EDA: quick look on the data
|
|
21
24
|
- 03_*: quick petropohysical interpretation of the MOCK wells.
|
|
22
25
|
- For API notebook, need to run the following before running the cells
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
python main.py app
|
|
24
28
|
|
|
25
29
|
## Install
|
|
26
30
|
To install, use the following command:
|
|
@@ -28,41 +32,55 @@ To install, use the following command:
|
|
|
28
32
|
`pip install quick_pp`
|
|
29
33
|
|
|
30
34
|
To use qpp_assistant, you would need to;
|
|
31
|
-
1.
|
|
32
|
-
2. Run `
|
|
35
|
+
1. Run `git clone https://github.com/imranfadhil/quick_pp.git`
|
|
36
|
+
2. Run `pip install -r requirements.txt`
|
|
37
|
+
3. Specify the required credentials in .env (based on `.env copy` file)
|
|
38
|
+
4. Run `docker-compose up -d`
|
|
39
|
+
5. Go to Langflow at http://localhost:7860 and build your flow.
|
|
40
|
+
6. Run `python main.py app` and go to the qpp Assistant at http://localhost:8888/qpp_assistant to test your flow.
|
|
33
41
|
|
|
34
42
|
## CLI
|
|
35
|
-
To start the App
|
|
36
|
-
> quick_pp app
|
|
37
|
-
|
|
38
|
-
You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
|
|
39
|
-
|
|
40
|
-
To use the mcp tools, you would need to first add the following SSE URLS through the interface;
|
|
41
|
-
http://localhost:8888/mcp - quick_pp tools.
|
|
42
|
-
|
|
43
|
-
http://localhost:5555/mcp - quick_pp ML model prediction tools (will only be available after ML models are trained and registered).
|
|
44
43
|
|
|
44
|
+
To train an ML model, these are the requirements;
|
|
45
45
|
|
|
46
|
-
To train an ML model, these are the requirements;
|
|
47
46
|
1. The input file in parquet format need to be available; /data/input/<data_hash>___.parquet
|
|
47
|
+
|
|
48
48
|
2. The parquet file need to have the input and target features as specified in MODELLING_CONFIG in config.py.
|
|
49
|
+
|
|
49
50
|
> quick_pp train <model_config> <data_hash>
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
quick_pp train mock mock
|
|
52
53
|
|
|
53
54
|
To run the MLflow server
|
|
54
|
-
|
|
55
|
+
|
|
56
|
+
quick_pp mlflow-server
|
|
57
|
+
|
|
58
|
+
You can access the mlflow server at http://localhost:5015
|
|
55
59
|
|
|
56
60
|
To run prediction, the trained models need to be registered in MLflow first.
|
|
61
|
+
|
|
57
62
|
> quick_pp predict <model_config> <data_hash>
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
quick_pp predict mock mock
|
|
60
65
|
|
|
61
|
-
To deploy the trained ML models
|
|
62
|
-
|
|
66
|
+
To deploy the trained ML models
|
|
67
|
+
|
|
68
|
+
quick_pp model-deployment
|
|
63
69
|
|
|
64
70
|
You can access the deployed model Swagger UI at http://localhost:5555/docs
|
|
65
71
|
|
|
72
|
+
To start the App
|
|
73
|
+
|
|
74
|
+
quick_pp app
|
|
75
|
+
|
|
76
|
+
You can then access the Swagger UI at http://localhost:8888/docs and qpp_assistant at http://localhost:8888/qpp_assistant.
|
|
77
|
+
You can enter any user name and password to login the qpp_assistant.
|
|
78
|
+
|
|
79
|
+
To use the mcp tools, you would need to first add the following SSE URLS through the interface;
|
|
80
|
+
http://localhost:8888/mcp - quick_pp tools.
|
|
81
|
+
|
|
82
|
+
http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
|
|
83
|
+
|
|
66
84
|
## Documentation
|
|
67
85
|
Documentation is available at:
|
|
68
86
|
<https://quick-pp.readthedocs.io/en/latest/index.html>
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quick-pp"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.5"
|
|
8
8
|
description = "Python package to assist in providing quick-look/ preliminary petrophysical estimation."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -28,11 +28,8 @@ classifiers = [
|
|
|
28
28
|
"Programming Language :: Python :: 3.11",
|
|
29
29
|
]
|
|
30
30
|
dependencies = [
|
|
31
|
-
"chainlit==2.5.5",
|
|
32
31
|
"Click>=7.0",
|
|
33
32
|
"fastapi",
|
|
34
|
-
"fastapi_mcp",
|
|
35
|
-
"langchain_ollama==0.3.3",
|
|
36
33
|
"loguru",
|
|
37
34
|
"matplotlib==3.8.0",
|
|
38
35
|
"mlflow",
|
|
@@ -40,6 +37,7 @@ dependencies = [
|
|
|
40
37
|
"pandas",
|
|
41
38
|
"psycopg2-binary",
|
|
42
39
|
"ptitprince",
|
|
40
|
+
"python-multipart",
|
|
43
41
|
"ruptures",
|
|
44
42
|
"SALib==1.5.1",
|
|
45
43
|
"scikit-learn",
|
|
@@ -17,3 +17,7 @@ logger.add(
|
|
|
17
17
|
# Silence overly verbose loggers from dependencies (if needed, using stdlib logging)
|
|
18
18
|
logging.getLogger("matplotlib").setLevel(logging.WARNING)
|
|
19
19
|
logging.getLogger("mlflow").setLevel(logging.WARNING)
|
|
20
|
+
|
|
21
|
+
__author__ = """Imran Fadhil"""
|
|
22
|
+
__email__ = 'imranfadhil@gmail.com'
|
|
23
|
+
__version__ = '0.2.5' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from fastapi import FastAPI, Request
|
|
2
|
+
from fastapi.responses import JSONResponse
|
|
3
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
4
|
+
from fastapi.staticfiles import StaticFiles
|
|
5
|
+
from fastapi.responses import FileResponse
|
|
6
|
+
from fastapi.templating import Jinja2Templates
|
|
7
|
+
from .exceptions import return_exception_message
|
|
8
|
+
try:
|
|
9
|
+
from fastapi_mcp import FastApiMCP
|
|
10
|
+
except ImportError:
|
|
11
|
+
FastApiMCP = None
|
|
12
|
+
from importlib import resources
|
|
13
|
+
import os
|
|
14
|
+
|
|
15
|
+
from .router import api_router
|
|
16
|
+
|
|
17
|
+
# Configuration
|
|
18
|
+
LANGFLOW_HOST = os.getenv("LANGFLOW_HOST", "http://localhost:7860")
|
|
19
|
+
|
|
20
|
+
tags_metadata = [
|
|
21
|
+
{
|
|
22
|
+
"name": "File Handler",
|
|
23
|
+
"description": "File handler related endpoints."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Lithology",
|
|
27
|
+
"description": "Lithology related endpoints."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "Porosity",
|
|
31
|
+
"description": "Porosity related endpoints."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "Saturation",
|
|
35
|
+
"description": "Saturation related endpoints."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "Permeability",
|
|
39
|
+
"description": "Permeability related endpoints."
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "Reservoir Summary",
|
|
43
|
+
"description": "Reservoir summary related endpoints."
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "Langflow",
|
|
47
|
+
"description": "Langflow related endpoints."
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
app = FastAPI(
|
|
52
|
+
title="quick_pp API",
|
|
53
|
+
description="API for quick_pp library.",
|
|
54
|
+
contact={"name": "Imran Fadhil",
|
|
55
|
+
"url": "https://github.com/imranfadhil/quick_pp", "email": "imranfadhil@gmail.com"},
|
|
56
|
+
swagger_ui_parameters={"defaultModelsExpandDepth": -1},
|
|
57
|
+
openapi_tags=tags_metadata,
|
|
58
|
+
debug=True
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Setup static files and templates
|
|
62
|
+
with resources.files('quick_pp.api') as api_folder:
|
|
63
|
+
static_folder = api_folder / "static"
|
|
64
|
+
template_folder = api_folder / "template"
|
|
65
|
+
|
|
66
|
+
app.mount("/static", StaticFiles(directory=static_folder), name="static")
|
|
67
|
+
|
|
68
|
+
# Initialize Jinja2 templates
|
|
69
|
+
templates = Jinja2Templates(directory=str(template_folder))
|
|
70
|
+
|
|
71
|
+
app.include_router(api_router)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@app.get("/favicon.ico", include_in_schema=False)
|
|
75
|
+
async def favicon():
|
|
76
|
+
return FileResponse(str(static_folder / "favicon.ico"))
|
|
77
|
+
|
|
78
|
+
origins = ["*"]
|
|
79
|
+
app.add_middleware(
|
|
80
|
+
CORSMiddleware,
|
|
81
|
+
allow_origins=origins,
|
|
82
|
+
allow_credentials=True,
|
|
83
|
+
allow_methods=origins,
|
|
84
|
+
allow_headers=origins,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@app.get("/", include_in_schema=False)
|
|
89
|
+
async def root(request: Request):
|
|
90
|
+
return templates.TemplateResponse("home.html", {"request": request})
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@app.get("/qpp_assistant", include_in_schema=False)
|
|
94
|
+
async def qpp_assistant(request: Request):
|
|
95
|
+
"""
|
|
96
|
+
Serve the Langflow chat interface with dynamic project/flow selection.
|
|
97
|
+
"""
|
|
98
|
+
# Get the base URL for API calls
|
|
99
|
+
base_url = str(request.base_url).rstrip('/')
|
|
100
|
+
|
|
101
|
+
# Configuration for the template
|
|
102
|
+
context = {
|
|
103
|
+
"request": request,
|
|
104
|
+
"api_base_url": base_url + "/quick_pp",
|
|
105
|
+
"langflow_host": LANGFLOW_HOST
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return templates.TemplateResponse("chat.html", context)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@app.exception_handler(Exception)
|
|
112
|
+
async def internal_server_exception_handler(exc: Exception):
|
|
113
|
+
return JSONResponse(
|
|
114
|
+
status_code=500,
|
|
115
|
+
content={
|
|
116
|
+
"message": return_exception_message(exc),
|
|
117
|
+
"detail": f"{repr(exc)}"
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if FastApiMCP is not None:
|
|
123
|
+
mcp = FastApiMCP(
|
|
124
|
+
app,
|
|
125
|
+
name="quick_pp API MCP",
|
|
126
|
+
describe_all_responses=True, # Include all possible response schemas
|
|
127
|
+
describe_full_response_schema=True # Include full JSON schema in descriptions
|
|
128
|
+
)
|
|
129
|
+
mcp.mount()
|
|
@@ -8,6 +8,7 @@ from datetime import datetime
|
|
|
8
8
|
import mlflow
|
|
9
9
|
from mlflow.pyfunc import load_model
|
|
10
10
|
import mlflow.tracking as mlflow_tracking
|
|
11
|
+
from importlib import resources
|
|
11
12
|
|
|
12
13
|
# # Uncomment below 3 lines to run >> if __name__ == "__main__"
|
|
13
14
|
# import os
|
|
@@ -15,8 +16,8 @@ import mlflow.tracking as mlflow_tracking
|
|
|
15
16
|
# sys.path.append(os.getcwd())
|
|
16
17
|
|
|
17
18
|
from quick_pp.api.fastapi_mlflow.applications import build_app
|
|
18
|
-
from quick_pp.
|
|
19
|
-
from quick_pp
|
|
19
|
+
from quick_pp.machine_learning.utils import get_model_info, run_mlflow_server
|
|
20
|
+
from quick_pp import logger
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
app = FastAPI(
|
|
@@ -26,7 +27,9 @@ app = FastAPI(
|
|
|
26
27
|
"url": "https://github.com/imranfadhil/quick_pp", "email": "imranfadhil@gmail.com"},
|
|
27
28
|
swagger_ui_parameters={"defaultModelsExpandDepth": -1},
|
|
28
29
|
debug=True)
|
|
29
|
-
|
|
30
|
+
with resources.files('quick_pp.api') as api_folder:
|
|
31
|
+
static_folder = api_folder / "public"
|
|
32
|
+
app.mount("/static", StaticFiles(directory=static_folder), name="static")
|
|
30
33
|
|
|
31
34
|
|
|
32
35
|
@app.get("/favicon.ico", include_in_schema=False)
|
|
@@ -6,7 +6,7 @@ from .services.porosity import router as porosity_router
|
|
|
6
6
|
from .services.saturation import router as saturation_router
|
|
7
7
|
from .services.permeability import router as permeability_router
|
|
8
8
|
from .services.reservoir_summary import router as ressum_router
|
|
9
|
-
|
|
9
|
+
from .services.chat import router as chat_router
|
|
10
10
|
|
|
11
11
|
api_router = APIRouter(prefix="/quick_pp")
|
|
12
12
|
|
|
@@ -16,3 +16,4 @@ api_router.include_router(porosity_router)
|
|
|
16
16
|
api_router.include_router(saturation_router)
|
|
17
17
|
api_router.include_router(permeability_router)
|
|
18
18
|
api_router.include_router(ressum_router)
|
|
19
|
+
api_router.include_router(chat_router)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from fastapi import APIRouter
|
|
2
|
+
import requests
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
router = APIRouter(prefix="/langflow", tags=["Langflow"])
|
|
6
|
+
|
|
7
|
+
# Configuration
|
|
8
|
+
local_url = os.getenv("LANGFLOW_HOST", "http://localhost:7860")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@router.get("/get_projects")
|
|
12
|
+
async def get_projects():
|
|
13
|
+
|
|
14
|
+
url = f"{local_url}/api/v1/projects/"
|
|
15
|
+
|
|
16
|
+
payload = {}
|
|
17
|
+
headers = {
|
|
18
|
+
"Accept": "application/json"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
response = requests.request("GET", url, headers=headers, data=payload)
|
|
22
|
+
|
|
23
|
+
return response.json()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@router.get("/get_projects_id")
|
|
27
|
+
async def get_projects_id():
|
|
28
|
+
projects = await get_projects()
|
|
29
|
+
return [{"id": project["id"], "name": project["name"]} for project in projects]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@router.get("/get_flows")
|
|
33
|
+
async def get_flows():
|
|
34
|
+
|
|
35
|
+
url = f"{local_url}/api/v1/flows/?remove_example_flows=true&get_all=true&header_flows=true"
|
|
36
|
+
|
|
37
|
+
payload = {}
|
|
38
|
+
headers = {
|
|
39
|
+
"Accept": "application/json"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
response = requests.request("GET", url, headers=headers, data=payload)
|
|
43
|
+
|
|
44
|
+
return response.json()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@router.get("/get_flows_id")
|
|
48
|
+
async def get_flows_id():
|
|
49
|
+
flows = await get_flows()
|
|
50
|
+
return [{"id": flow["id"], "name": flow["name"]} for flow in flows]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@router.post("/chat")
|
|
54
|
+
async def chat(flow_id: str, question: str):
|
|
55
|
+
import requests
|
|
56
|
+
url = f"{local_url}/api/v1/run/{flow_id}" # The complete API endpoint URL for this flow
|
|
57
|
+
|
|
58
|
+
# Request payload configuration
|
|
59
|
+
payload = {
|
|
60
|
+
"input_value": question, # The input value to be processed by the flow
|
|
61
|
+
"output_type": "chat", # Specifies the expected output format
|
|
62
|
+
"input_type": "chat" # Specifies the input format
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Request headers
|
|
66
|
+
headers = {
|
|
67
|
+
"Content-Type": "application/json"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
# Send API request
|
|
72
|
+
response = requests.request("POST", url, json=payload, headers=headers)
|
|
73
|
+
response.raise_for_status() # Raise exception for bad status codes
|
|
74
|
+
|
|
75
|
+
# Extract the text message from the nested response structure
|
|
76
|
+
response_data = response.json()
|
|
77
|
+
|
|
78
|
+
# Navigate through the nested structure to get the text message
|
|
79
|
+
if response_data and "outputs" in response_data:
|
|
80
|
+
outputs = response_data["outputs"]
|
|
81
|
+
if outputs and len(outputs) > 0:
|
|
82
|
+
response_data = outputs[0]['outputs'][0]['results']
|
|
83
|
+
|
|
84
|
+
# Fallback: return the full response if structure is different
|
|
85
|
+
return response_data
|
|
86
|
+
|
|
87
|
+
except requests.exceptions.RequestException as e:
|
|
88
|
+
print(f"Error making API request: {e}")
|
|
89
|
+
return {"error": f"Request error: {str(e)}"}
|
|
90
|
+
except ValueError as e:
|
|
91
|
+
print(f"Error parsing response: {e}")
|
|
92
|
+
return {"error": f"Parsing error: {str(e)}"}
|
|
@@ -103,7 +103,7 @@ async def estimate_ssc(inputs: LithologySSCInput):
|
|
|
103
103
|
List of dictionaries, each containing the estimated volume fractions:
|
|
104
104
|
- 'VSAND': float (sand fraction)
|
|
105
105
|
- 'VSILT': float (silt fraction)
|
|
106
|
-
- '
|
|
106
|
+
- 'VCLAY': float (clay fraction)
|
|
107
107
|
|
|
108
108
|
Raises
|
|
109
109
|
------
|
|
@@ -129,7 +129,7 @@ async def estimate_ssc(inputs: LithologySSCInput):
|
|
|
129
129
|
silt_line_angle=input_dict['silt_line_angle']
|
|
130
130
|
)
|
|
131
131
|
vsand, vsilt, vcld, _ = ssc_model.estimate_lithology(df['nphi'], df['rhob'])
|
|
132
|
-
return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, '
|
|
132
|
+
return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLAY': vcld}, index=df.index).to_dict(orient='records')
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
@router.post(
|
|
@@ -240,7 +240,7 @@ async def estimate_hc_correction(inputs: LithologyHCCorrectionInput):
|
|
|
240
240
|
List of dictionaries, each containing the estimated volume fractions:
|
|
241
241
|
- 'VSAND': float (sand fraction)
|
|
242
242
|
- 'VSILT': float (silt fraction)
|
|
243
|
-
- '
|
|
243
|
+
- 'VCLAY': float (clay fraction)
|
|
244
244
|
|
|
245
245
|
Raises
|
|
246
246
|
------
|
|
@@ -275,4 +275,4 @@ async def estimate_hc_correction(inputs: LithologyHCCorrectionInput):
|
|
|
275
275
|
silt_line_angle=input_dict['silt_line_angle']
|
|
276
276
|
)
|
|
277
277
|
vsand, vsilt, vcld, _ = ssc_model.estimate_lithology(df_corr['NPHI'], df_corr['RHOB'])
|
|
278
|
-
return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, '
|
|
278
|
+
return pd.DataFrame({'VSAND': vsand, 'VSILT': vsilt, 'VCLAY': vcld}, index=df.index).to_dict(orient='records')
|