diff --git a/docs/examples/simple/data.ipynb b/docs/examples/simple/data.ipynb index c185c0a..e54811b 100644 --- a/docs/examples/simple/data.ipynb +++ b/docs/examples/simple/data.ipynb @@ -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", + ")" ] }, { diff --git a/docs/examples/simple/deploy.ipynb b/docs/examples/simple/deploy.ipynb index da874c8..62cbca5 100644 --- a/docs/examples/simple/deploy.ipynb +++ b/docs/examples/simple/deploy.ipynb @@ -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", diff --git a/docs/how-to-guides/configure-service.md b/docs/how-to-guides/configure-service.md index 47534fa..e746146 100644 --- a/docs/how-to-guides/configure-service.md +++ b/docs/how-to-guides/configure-service.md @@ -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]. diff --git a/docs/how-to-guides/create-service.md b/docs/how-to-guides/create-service.md index 210bdd7..19307b0 100644 --- a/docs/how-to-guides/create-service.md +++ b/docs/how-to-guides/create-service.md @@ -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 diff --git a/docs/how-to-guides/use-service.md b/docs/how-to-guides/use-service.md index 6014889..a1ee367 100644 --- a/docs/how-to-guides/use-service.md +++ b/docs/how-to-guides/use-service.md @@ -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 }. diff --git a/docs/tutorial/deploy.ipynb b/docs/tutorial/deploy.ipynb index c239d3a..cfbb35e 100644 --- a/docs/tutorial/deploy.ipynb +++ b/docs/tutorial/deploy.ipynb @@ -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)" ] diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md index 6edb8d1..9cdaa32 100644 --- a/docs/tutorial/index.md +++ b/docs/tutorial/index.md @@ -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)
-[: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 }