Fix docs
This commit is contained in:
parent
6331ede9a2
commit
a61e8709d3
7 changed files with 29 additions and 21 deletions
|
|
@ -66,7 +66,7 @@ from great_ai import GreatAI, use_model
|
|||
def type_safe_greeter(your_name: str, model) -> str:
|
||||
return f'Hi {your_name}!'
|
||||
|
||||
assert type_safe_greeter('Andras').output == 'Hi Andras'
|
||||
assert type_safe_greeter('Andras').output == 'Hi Andras!'
|
||||
```
|
||||
|
||||
1. By default, the parameter named `model` will be replaced by the loaded model. This behaviour can be customised by setting the `model_kwarg_name`. This way, even multiple models can be injected into a single function.
|
||||
|
|
@ -82,14 +82,14 @@ If you wish to turn off logging or specify custom validation for your parameters
|
|||
By default, all parameters that are not affected by an explicit [@parameter][great_ai.parameter] or [@use_model][great_ai.use_model] are automatically decorated with [@parameter][great_ai.parameter] when [@GreatAI.create][great_ai.GreatAI.create] is called.
|
||||
|
||||
```python title="greeter_with_validation.py"
|
||||
from great_ai import GreatAI, use_model
|
||||
from great_ai import GreatAI, parameter
|
||||
|
||||
@GreatAI.create
|
||||
@parameter('your_name', disable_logging=True)
|
||||
def type_safe_greeter(your_name: str, model) -> str:
|
||||
def type_safe_greeter(your_name: str) -> str:
|
||||
return f'Hi {your_name}!'
|
||||
|
||||
assert type_safe_greeter('Andras').output == 'Hi Andras'
|
||||
assert type_safe_greeter('Andras').output == 'Hi Andras!'
|
||||
```
|
||||
|
||||
!!! important
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# How to use LargeFiles
|
||||
|
||||
The functions [save_model][great_ai.use_model] and [@use_model][great_ai.use_model] wrap LargeFile instances. Hence, besides configuring [LargeFile](https://great-ai.schmelczer.dev/reference/large-file), users have few reasons to use LargeFiles directly.
|
||||
The functions [save_model][great_ai.save_model] and [@use_model][great_ai.use_model] wrap LargeFile instances. Hence, besides configuring [LargeFile](https://great-ai.schmelczer.dev/reference/large-file), users have few reasons to use LargeFiles directly.
|
||||
|
||||
## Motivation
|
||||
|
||||
|
|
@ -16,12 +16,12 @@ Often, especially when working with data-heavy applications, large files can pro
|
|||
```python
|
||||
from great_ai.large_file import LargeFileS3
|
||||
|
||||
LargeFileS3.configure_credentials({
|
||||
"aws_region_name": "your_region_like_eu-west-2",
|
||||
"aws_access_key_id": "YOUR_ACCESS_KEY_ID",
|
||||
"aws_secret_access_key": "YOUR_VERY_SECRET_ACCESS_KEY",
|
||||
"large_files_bucket_name": "create_a_bucket_and_put_its_name_here",
|
||||
})
|
||||
LargeFileS3.configure_credentials(
|
||||
aws_region_name="your_region_like_eu-west-2",
|
||||
aws_access_key_id="YOUR_ACCESS_KEY_ID",
|
||||
aws_secret_access_key="YOUR_VERY_SECRET_ACCESS_KEY",
|
||||
large_files_bucket_name="create_a_bucket_and_put_its_name_here",
|
||||
)
|
||||
|
||||
# Creates a new version and deletes the older version
|
||||
# leaving the three most recently used intact
|
||||
|
|
@ -44,6 +44,8 @@ Often, especially when working with data-heavy applications, large files can pro
|
|||
The local cache can be configured with these properties:
|
||||
|
||||
```python
|
||||
from pathlib import Path
|
||||
|
||||
LargeFileS3.cache_path = Path('.cache')
|
||||
LargeFileS3.max_cache_size = "30 GB"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,16 +4,21 @@ import json
|
|||
import os
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DATA_DIR = ROOT / "docs/tutorial/data"
|
||||
SURVEY_DIR = ROOT / "docs/surveys"
|
||||
FULL_RUN = os.environ.get("GREAT_AI_NOTEBOOK_FULL") == "1"
|
||||
|
||||
|
||||
def setup_notebook(root: Path, workflow: str) -> Path:
|
||||
def setup_notebook(workflow: str) -> Path:
|
||||
"""Keep related notebooks' models and traces together, outside source files."""
|
||||
from great_ai import ParallelTinyDbDriver, configure
|
||||
from great_ai.large_file import LargeFileLocal
|
||||
|
||||
base = Path(os.environ.get("GREAT_AI_NOTEBOOK_WORKDIR", root / ".cache/notebooks"))
|
||||
suffix = "-full" if os.environ.get("GREAT_AI_NOTEBOOK_FULL") == "1" else ""
|
||||
base = Path(os.environ.get("GREAT_AI_NOTEBOOK_WORKDIR", ROOT / ".cache/notebooks"))
|
||||
suffix = "-full" if FULL_RUN else ""
|
||||
work_dir = (base / (workflow + suffix)).resolve()
|
||||
work_dir.mkdir(parents=True, exist_ok=True)
|
||||
LargeFileLocal.cache_path = work_dir / "models-cache"
|
||||
|
|
@ -43,7 +48,7 @@ def mag_lines(path: Path, per_label: Optional[int] = None) -> List[str]:
|
|||
|
||||
def demo_annotations() -> List[dict]:
|
||||
"""Synthetic annotations for exercising the pipeline, not measuring quality."""
|
||||
annotations = [{}, {}]
|
||||
annotations: List[Dict[str, int]] = [{}, {}]
|
||||
for index, topic in enumerate(
|
||||
["protein", "cancer", "solar", "quantum", "neural", "genome"]
|
||||
):
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ After training and evaluating a model, it is exported using [great_ai.save_model
|
|||
```python
|
||||
from great_ai.large_file import LargeFileS3
|
||||
|
||||
LargeFileS3.configure(
|
||||
LargeFileS3.configure_credentials(
|
||||
aws_region_name='eu-west-2',
|
||||
aws_access_key_id='MY_AWS_ACCESS_KEY',
|
||||
aws_secret_access_key='MY_AWS_SECRET_KEY',
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ markdown_extensions:
|
|||
- pymdownx.details
|
||||
- md_in_html
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
- abbr
|
||||
- attr_list
|
||||
- pymdownx.caret
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ dev = [
|
|||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
# Collect doctests and tests from the checkout even when a wheel is installed.
|
||||
pythonpath = ["."]
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
# `...` in doctests (e.g. third-party exception messages that drift between
|
||||
# dependency versions) is treated as a wildcard rather than a literal.
|
||||
doctest_optionflags = ["ELLIPSIS"]
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -4,8 +4,6 @@ isolated_build = True
|
|||
|
||||
[testenv]
|
||||
alwayscopy = True
|
||||
setenv =
|
||||
PY_IGNORE_IMPORTMISMATCH = 1
|
||||
deps =
|
||||
pytest
|
||||
pytest-cov
|
||||
|
|
|
|||
Loading…
Reference in a new issue