Minor fixes
This commit is contained in:
parent
8c7a31a513
commit
b1a66cb579
7 changed files with 30 additions and 13 deletions
|
|
@ -92,7 +92,13 @@
|
|||
"from typing import List, Tuple\n",
|
||||
"import json\n",
|
||||
"import gzip\n",
|
||||
"from great_ai.utilities import simple_parallel_map, clean, is_english, predict_language, unchunk\n",
|
||||
"from great_ai.utilities import (\n",
|
||||
" simple_parallel_map,\n",
|
||||
" clean,\n",
|
||||
" is_english,\n",
|
||||
" predict_language,\n",
|
||||
" unchunk,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def preprocess_chunk(chunk_key: str) -> List[Tuple[str, List[str]]]:\n",
|
||||
|
|
@ -119,7 +125,9 @@
|
|||
" ]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"preprocessed_data = unchunk(simple_parallel_map(preprocess_chunk, chunks, concurrency=4))"
|
||||
"preprocessed_data = unchunk(\n",
|
||||
" simple_parallel_map(preprocess_chunk, chunks, concurrency=4)\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
" parameter,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@GreatAI.create\n",
|
||||
"@use_model(\"small-domain-prediction\", version=\"latest\")\n",
|
||||
"@parameter(\"target_confidence\", validator=lambda c: 0 <= c <= 100)\n",
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ configure(
|
|||
|
||||
The only aspect that cannot be automated is choosing the backing storage for the database and file storage.
|
||||
|
||||
Right now, you have 3 options for storing the models and large datasets: [great_ai.large_file.LargeFileLocal][], [great_ai.large_file.LargeFileMongo][], and [great_ai.large_file.LargeFileS3][].
|
||||
Right now, you have 3 options for storing the models and large datasets: [LargeFileLocal][great_ai.large_file.LargeFileLocal], [LargeFileMongo][great_ai.large_file.LargeFileMongo], and [LargeFileS3][great_ai.large_file.LargeFileS3].
|
||||
|
||||
Without explicit configuration, [great_ai.large_file.LargeFileLocal][] is selected by default. This one still version-controls your files but it only stores them in a local path.
|
||||
Without explicit configuration, [LargeFileLocal][great_ai.large_file.LargeFileLocal] is selected by default. This one still version-controls your files but it only stores them in a local path.
|
||||
|
||||
!!! important
|
||||
If your working directory contains a `mongo.ini` or `s3.ini` file, an attempt is made to auto-configure [LargeFileMongo][great_ai.large_file.LargeFileMongo] or [LargeFileS3][great_ai.large_file.LargeFileS3] respectively.
|
||||
|
|
@ -76,6 +76,7 @@ save_model(model, 'my-model')
|
|||
MONGO_CONNECTION_STRING=mongodb://localhost:27017 # this is the default value
|
||||
# if `MONGO_CONNECTION_STRING` is specified, this default is overridden
|
||||
MONGO_CONNECTION_STRING=ENV:MONGO_CONNECTION_STRING
|
||||
|
||||
MONGO_DATABASE=my-database # it is automatically created if doesn't exist
|
||||
```
|
||||
|
||||
|
|
@ -98,4 +99,4 @@ By default, a thread-safe version of [TinyDB](https://tinydb.readthedocs.io/en/l
|
|||
|
||||
### MongoDB
|
||||
|
||||
At the moment, only MongoDB is supported as a production-ready `TracingDatabase`. In order to use it, you have to either place a file named `mongo.ini` in your working directory, or explicitly call [MongoDbDriver.configure_credentials_from_file][great_ai.MongoDbDriver.configure_credentials_from_file] or [MongoDbDriver.configure_credentials][great_ai.MongoDbDriver.configure_credentials].
|
||||
At the moment, only MongoDB is supported as a production-ready `TracingDatabase`. In order to use it, you have to either place a file named `mongo.ini` in your working directory, or explicitly call [MongoDbDriver.configure_credentials_from_file][great_ai.MongoDbDriver] or [MongoDbDriver.configure_credentials][great_ai.MongoDbDriver.configure_credentials].
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def greeter(your_name):
|
|||
|
||||
## With types
|
||||
|
||||
[Type annotating your codebase](https://realpython.com/python-type-checking/){ target=_blank } can save you from lots of trivial mistakes, that's why it's highly advised. Simply add the expected types to your function's signature.
|
||||
Even though it's not required by GreatAI, [type annotating your codebase](https://realpython.com/python-type-checking/){ target=_blank } can save you from lots of trivial mistakes, that's why it's highly advised. Simply add the expected types to your function's signature.
|
||||
|
||||
```python title="type_safe_greeter.py"
|
||||
from great_ai import GreatAI
|
||||
|
|
@ -100,7 +100,7 @@ assert type_safe_greeter('Andras').output == 'Hi Andras'
|
|||
Refer to the following example summarising the options you have when instantiating a GreatAI service.
|
||||
|
||||
```python title="complex.py"
|
||||
from great_ai import save_model, GreatAI, parameter, use_model
|
||||
from great_ai import save_model, GreatAI, parameter, use_model, log_metric
|
||||
|
||||
save_model(4, 'secret-number') #(1)
|
||||
|
||||
|
|
@ -108,6 +108,10 @@ save_model(4, 'secret-number') #(1)
|
|||
@parameter('positive_number', validator=lambda n: n > 0, disable_logging=True)
|
||||
@use_model('secret-number', version='latest', model_kwarg_name='secret')
|
||||
def add_number(positive_number: int, secret: int) -> int:
|
||||
log_metric(
|
||||
'log directly into the returned Trace',
|
||||
positive_number * 2
|
||||
)
|
||||
return positive_number + secret
|
||||
|
||||
assert add_number(1).output == 5
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ Some configuration options are also supported.
|
|||
```sh
|
||||
great-ai greeter.py --port 8000 --host 127.0.0.1 --timeout_keep_alive 10
|
||||
```
|
||||
> For more options (but no Notebook support, use [uvicorn](https://www.uvicorn.org/){ target=_blank })
|
||||
??? note "More options"
|
||||
For more options (but no Notebook support), simply use [uvicorn](https://www.uvicorn.org/){ target=_blank } for starting your app (available at `greeter.app`).
|
||||
|
||||
### In production
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ docker run -p 6060:6060 --volume `pwd`:/app --rm \
|
|||
|
||||
#### Use a Platform-as-a-Service
|
||||
|
||||
Similarly to the previous approach, your code will run in a container. However, instead of manually managing it, you can just choose from a plethora of PaaS providers (such as [DO App platform](https://www.digitalocean.com/products/app-platform){ target=_blank } or [MLEM](https://mlem.ai/){ target=_blank }) that take a Docker image as a source and handle the rest of the deployment.
|
||||
Similarly to the previous approach, your code will run in a container. However, instead of manually managing it, you can just choose from a plethora of PaaS providers (such as [AWS ECS](https://aws.amazon.com/ecs/){ target=_blank }, [DO App platform](https://www.digitalocean.com/products/app-platform){ target=_blank }, [MLEM](https://mlem.ai/){ target=_blank }) that take a Docker image as a source and handle the rest of the deployment.
|
||||
|
||||
To this end, you can also create a custom Docker image. It is especially useful if you have third-party dependencies, such as [PyTorch](https://pytorch.org/){ target=_blank } or [TensorFlow](https://www.tensorflow.org/){ target=_blank }.
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@
|
|||
"\n",
|
||||
"There are three main approaches to deploy a GreatAI service: For more info about them, check out [the deployment how-to](/how-to-guides/use-service).\n",
|
||||
"\n",
|
||||
"For more thorough examples, see the [examples page](/examples).\n",
|
||||
"For more thorough examples, see the [examples page](/examples/simple/data).\n",
|
||||
"\n",
|
||||
"### [Go back to the summary](/tutorial/#summary)"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ We use the same synthetic dataset derived from the [Microsoft Academic Graph](ht
|
|||
|
||||
## Summary
|
||||
|
||||
### The [training notebook](train.ipynb)
|
||||
### [Training notebook](train.ipynb)
|
||||
|
||||
We load and preprocess the dataset while relying on [great_ai.utilities.clean][great_ai.utilities.clean.clean] for doing the heavy-lifting. Additionally, the preprocessing is parallelised using [great_ai.utilities.simple_parallel_map][]
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ After training and evaluating a model, it is exported using [great_ai.save_model
|
|||
|
||||
For more info, checkout [the configuration how-to page](/how-to-guides/configure-service).
|
||||
|
||||
### The [deployment notebook](deploy.ipynb)
|
||||
### [Deployment notebook](deploy.ipynb)
|
||||
|
||||
We create an inference function that can be hardened by wrapping it in a [GreatAI][great_ai.GreatAI] instance.
|
||||
|
||||
|
|
@ -73,5 +73,7 @@ def predict_domain(sentence, model):
|
|||
Finally, we test the model's inference function through the GreatAI dashboard. [The only thing left is to deploy the hardened-service properly.](/how-to-guides/use-service)
|
||||
|
||||
<div style="display: flex; justify-content: center;" markdown>
|
||||
[:material-book: Learn about more features](/how-to-guides/create-service){ .md-button .md-button--primary }
|
||||
[:material-book: Learn about all the features](/how-to-guides/create-service){ .md-button .md-button--primary }
|
||||
|
||||
[:material-test-tube: Look at more examples](/examples/simple/data){ .md-button .md-button--secondary }
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue