Opinionated machine learning organization and configuration
Project description
# microcosm-sagemaker
Opinionated machine learning with SageMaker
## Usage
After creating a new model, there are a few steps to integrate with microcosm-sagemaker.
1. Create a training graph
The training graph holds the dependencies that are required at train time. These typically include the bundles you have defined or any related helper functions.
```py
from microcosm_sagemaker.loaders import load_train_conventions
def create_app(debug=False, testing=False):
config_loader = load_each(
load_from_environ,
load_train_conventions,
)
graph = create_object_graph(
name="my model",
)
graph.use(
"active_bundle",
"my_primary_bundle",
)
return graph.lock()
```
2. Create a service graph.
The service graph holds the dependencies that are required at service time. These typically include Flask and the web service routes.
```py
from microcosm_sagemaker.loaders import load_model_artifact_config
def create_app(artifact_path, debug=False, testing=False, model_only=False):
loader = load_each(
load_model_artifact_config(artifact_path),
)
graph = create_object_graph(
name="my model",
)
graph.use(
"active_bundle",
"active_evaluation",
)
if not model_only:
graph.use(
"my_primary_bundle",
"my_primary_evaluator",
)
return graph.lock()
```
3. Expose the graphs in `setup.py`.
```py
setup(
name="my_model",
entry_points={
"microcosm_sagemaker.app_hooks": [
"train = my_model.train.app:create_app",
"serve = my_model.serve.app:create_app",
],
},
)
```
Opinionated machine learning with SageMaker
## Usage
After creating a new model, there are a few steps to integrate with microcosm-sagemaker.
1. Create a training graph
The training graph holds the dependencies that are required at train time. These typically include the bundles you have defined or any related helper functions.
```py
from microcosm_sagemaker.loaders import load_train_conventions
def create_app(debug=False, testing=False):
config_loader = load_each(
load_from_environ,
load_train_conventions,
)
graph = create_object_graph(
name="my model",
)
graph.use(
"active_bundle",
"my_primary_bundle",
)
return graph.lock()
```
2. Create a service graph.
The service graph holds the dependencies that are required at service time. These typically include Flask and the web service routes.
```py
from microcosm_sagemaker.loaders import load_model_artifact_config
def create_app(artifact_path, debug=False, testing=False, model_only=False):
loader = load_each(
load_model_artifact_config(artifact_path),
)
graph = create_object_graph(
name="my model",
)
graph.use(
"active_bundle",
"active_evaluation",
)
if not model_only:
graph.use(
"my_primary_bundle",
"my_primary_evaluator",
)
return graph.lock()
```
3. Expose the graphs in `setup.py`.
```py
setup(
name="my_model",
entry_points={
"microcosm_sagemaker.app_hooks": [
"train = my_model.train.app:create_app",
"serve = my_model.serve.app:create_app",
],
},
)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microcosm-sagemaker-0.2.0.tar.gz
(16.0 kB
view hashes)
Close
Hashes for microcosm-sagemaker-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 717a278c8b726738352b80e8c056984a34e3783cd4091c9b48bcd8c02870669d |
|
MD5 | 2318281ab7e6e7501b991cff75b05a46 |
|
BLAKE2b-256 | e41951a10ba5c572c89c14e1e65af921d64b4e330a45c0cdfff98a1a94d58b59 |