Skip to content

Commit afeaa62

Browse files
authored
Lazy import of kedro fastapi modules and configs (#23)
* 🐛 Catch fastapi extra dependecies errors, and make their imports lazy. * ✨ Include ["fastapi*/] dynamically in the config loader config patterns
1 parent 5cacf45 commit afeaa62

File tree

14 files changed

+6095
-24
lines changed

14 files changed

+6095
-24
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- :sparkles: Include ["fastapi*/] dynamically in the config loader config patterns
8+
9+
### Fixed
10+
11+
- :bug: Catch fastapi extra dependecies errors, and make their imports lazy.
12+
513
## [0.2.0] - 2024-02-12
614

715
### Added
816

9-
- :sparkles: Introduce Kedro FastAPI Server: A framework for building production-ready REST APIs using Kedro, FastAPI and Gunicorn.
17+
- :sparkles: Introduce Kedro FastAPI Server: A framework for building production-ready REST APIs using Kedro, FastAPI and Gunicorn ([#18](https://github.com/takikadiri/kedro-boot/pull/18))
1018
- :sparkles: Support dataset factories ([#5](https://github.com/takikadiri/kedro-boot/pull/5))
1119
- :sparkles: Allow declaring apps through project settings and CLIs ([#16](https://github.com/takikadiri/kedro-boot/pull/16))
1220
- :sparkles: Adding `boot_project` and `boot_package` allowing standalone apps to boot a session ([#17](https://github.com/takikadiri/kedro-boot/pull/17))

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ pip install kedro-boot[fastapi]
3232
Then you can serve your fastapi app with :
3333
3434
```
35-
kedro boot fastapi --app path.to.your.fastapi.app <kedro_args>
35+
kedro boot fastapi --app path.to.your.fastapi.app <kedro_run_args>
3636
```
3737
3838
Your fastapi app objects will be mapped with kedro pipeline objects, and the run results will be injected into your KedroFastAPI object through [FastAPI dependency injection](https://fastapi.tiangolo.com/tutorial/dependencies/). Here is an illustration of the kedro <-> fastapi objects mapping:
3939
4040
![Kedro FastAPI objects mapping](.github/kedro_fastapi_mapping.PNG)
4141
42-
A default FastAPI app is used if no FastAPI app given. It would serve a single endpoint that run your selected pipeline
42+
A default FastAPI app is used if no FastAPI app given. It would serve a single endpoint that run in background your selected pipeline
4343
4444
```
45-
kedro boot fastapi
45+
kedro boot fastapi <kedro_run_args>
4646
```
4747
4848
These production-ready features would be natively included in your FastAPI apps:
@@ -51,7 +51,7 @@ These production-ready features would be natively included in your FastAPI apps:
5151
- [Pyctuator](https://github.com/SolarEdgeTech/pyctuator) that report some service health metrology and application states. Usually used by service orchestrators (kubernetes) or monitoring to track service health and ensure it's high availability
5252
- Multiple environments configurations, leveraging kedro's OmegaConfigLoader. ``["fastapi*/"]`` config pattern could be used to configure the web server. Configs could also be passed as CLI args (refer to --help)
5353
54-
You can refer to the spaceflights [Kedro FastAPI examples](examples/src/spaceflights_kedro_fastapi/app.py) that showcases serving multiples endpoints operations that are mapped to differents pipeline namespaces
54+
You can learn more by testing the [spaceflights Kedro FastAPI example](examples/README.md#rest-api-with-kedro-fastapi-server) that showcases serving multiples endpoints operations that are mapped to differents pipeline namespaces
5555
5656
5757
## Consuming Kedro pipelines through SDK
@@ -94,19 +94,19 @@ return {"__default__": spaceflights_pipelines}
9494

9595
In this example, all the namespaces and their namespaced datasets (inputs, outputs, parameters) would infer compilation specs and therefore would be exposed to the Application.
9696

97-
You can use kedro-viz to visualize the datasets that woulc be exposed to the kedro boot apps. In the figure below, we see clearly that ``inference.feature_store`` and ``inference.predictions`` will be exposed to the applicaton (the blue one).
97+
You can use kedro-viz to visualize the datasets that woulc be exposed to the kedro boot apps. In the figure below, for the ``inference`` namespace, we see clearly that ``inference.feature_store`` and ``inference.predictions`` will be exposed to the applicaton (the blue one).
9898

9999
![pipeline_namespace](.github/pipeline_namespace.png)
100100

101-
Below are the different categories of datasets that forms the compiled catalog.
101+
Below are the differents categories of datasets that forms the compiled catalog.
102102

103103
- Inputs: inputs datasets that are be injected by the app at iteration time.
104104
- Outputs: outputs dataset that hold the run results.
105105
- Parameters: parameters that are injected by the app at iteration time.
106106
- Artifacts: artifacts datasets that are materialized (loaded as MemoryDataset) at startup time.
107107
- Templates: template datasets that contains ${itertime_params: param_name}. Their attributes are interpolated at iteration time.
108108

109-
You can compile the catalog without actually using it in a Kedro Boot App. This is helpful for verifying if the expected artifacts datasets are correctly infered or if the template datasets are correctly detected.
109+
You can compile the catalog without actually using it in a Kedro Boot App. This is helpful for verifying if the expected artifacts datasets are correctly infered or if the template datasets are correctly detected. Here is an example of the catalog compilation report for a pipeline that contains an ``inference`` namespace.
110110

111111
```
112112
kedro boot compile
@@ -164,7 +164,7 @@ session = boot_project(
164164
run_results = session.run(inputs={"your_dataset_name": your_data})
165165
```
166166

167-
You can found a complete example of a steamlit app that serve an ML model in the [Kedro Boot Examples](examples) project. We invite you to test it to gain a better understanding of Kedro Boot's ``boot_project`` or ``boot_package`` interfaces
167+
You can found a complete example of a steamlit app that serve an ML model in the [Kedro Boot Examples](examples/README.md#data-app-with-streamlit-standalone-mode) project. We invite you to test it to gain a better understanding of Kedro Boot's ``boot_project`` or ``boot_package`` interfaces
168168

169169
### Embedded mode : The application is embeded inside kedro project
170170

@@ -212,7 +212,7 @@ kedro boot run <kedro_run_args>
212212
kedro boot run --app path.to.your.KedroBootApp <kedro_run_args>
213213
````
214214
215-
You can fnd two examples of using the embeded mode in the [Kedro Boot Examples](examples) project
215+
You can find an example of a [Monte Carlo App embeded into a kedro project](examples/README.md#monte-carlo-simulation-embeded-mode)
216216
217217
218218
## Why does Kedro Boot exist ?

examples/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ data/**
1919

2020
# keep also the example dataset
2121
!data/01_raw/*
22+
!data/04_feature/*
23+
!data/06_models/*
2224

2325

2426
##########################

examples/conf/base/fastapi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
server:
2-
port: 8002
2+
port: 8000

0 commit comments

Comments
 (0)