diff --git a/great_ai/__init__.py b/great_ai/__init__.py index 2d74d91..fdefdc8 100644 --- a/great_ai/__init__.py +++ b/great_ai/__init__.py @@ -1,5 +1,5 @@ -"""GreatAI""" -__version__ = "0.1.0" +"""GreatAI.""" +__version__ = "0.1.1" from .context import configure @@ -10,15 +10,17 @@ from .errors import ( RemoteCallError, WrongDecoratorOrderError, ) -from .models import save_model, use_model -from .output_views import ( - ClassificationOutput, - MultiLabelClassificationOutput, - RegressionOutput, -) +from .models.save_model import save_model +from .models.use_model import use_model from .parameters.log_metric import log_metric from .parameters.parameter import parameter from .persistence import MongodbDriver, ParallelTinyDbDriver, TracingDatabaseDriver from .remote import call_remote_great_ai, call_remote_great_ai_async from .tracing import add_ground_truth, delete_ground_truth, query_ground_truth -from .views import RouteConfig, Trace +from .views import ( + ClassificationOutput, + MultiLabelClassificationOutput, + RegressionOutput, + RouteConfig, + Trace, +) diff --git a/great_ai/deploy/great_ai.py b/great_ai/deploy/great_ai.py index 48df0e5..1d59840 100644 --- a/great_ai/deploy/great_ai.py +++ b/great_ai/deploy/great_ai.py @@ -23,7 +23,7 @@ from tqdm.cli import tqdm from ..constants import DASHBOARD_PATH from ..context import get_context from ..helper import freeze_arguments, get_function_metadata_store, snake_case_to_text -from ..models import model_versions +from ..models.use_model import model_versions from ..parameters.automatically_decorate_parameters import ( automatically_decorate_parameters, ) @@ -58,7 +58,10 @@ class GreatAI(Generic[T, V]): self._wrapped_func = wraps(func)(freeze_arguments(self._cached_func)) wraps(func)(self) - self.__doc__ = f"GreatAI wrapper for interacting with the `{self.__name__}` function.\n\n{dedent(self.__doc__ or '')}" + self.__doc__ = ( + f"GreatAI wrapper for interacting with the `{self.__name__}` " + + f"function.\n\n{dedent(self.__doc__ or '')}" + ) self.version = str(get_context().version) flat_model_versions = ".".join(f"{k}-v{v}" for k, v in model_versions) @@ -79,7 +82,7 @@ class GreatAI(Generic[T, V]): @overload @staticmethod def create( # type: ignore - # "Overloaded function signatures 1 and 2 overlap with incompatible return types" + # Overloaded function signatures 1 and 2 overlap with incompatible return types # https://github.com/python/mypy/issues/12759 func: Callable[..., Awaitable[V]], ) -> "GreatAI[Awaitable[Trace[V]], V]": @@ -131,8 +134,8 @@ class GreatAI(Generic[T, V]): Returns: A GreatAI instance wrapping `func`. - """ + return GreatAI[Trace[V], V]( func, ) diff --git a/great_ai/deploy/routes/dashboard/assets/index.css b/great_ai/deploy/routes/dashboard/assets/index.css index f4003e7..3a0d358 100644 --- a/great_ai/deploy/routes/dashboard/assets/index.css +++ b/great_ai/deploy/routes/dashboard/assets/index.css @@ -206,10 +206,6 @@ main > header .placeholder { flex-grow: 1; } -main > footer { - margin: 0; -} - main > footer { display: flex; justify-content: space-between; diff --git a/great_ai/helper/__init__.py b/great_ai/helper/__init__.py index ea285ab..8f29d76 100644 --- a/great_ai/helper/__init__.py +++ b/great_ai/helper/__init__.py @@ -1,7 +1,6 @@ from .freeze_arguments import freeze, freeze_arguments from .get_arguments import get_arguments from .get_function_metadata_store import get_function_metadata_store -from .hashable_base_model import HashableBaseModel from .snake_case_to_text import snake_case_to_text from .strip_lines import strip_lines from .text_to_hex_color import text_to_hex_color diff --git a/great_ai/helper/get_arguments.py b/great_ai/helper/get_arguments.py index be05f2c..af575d1 100644 --- a/great_ai/helper/get_arguments.py +++ b/great_ai/helper/get_arguments.py @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Mapping, Sequence def get_arguments( func: Callable, args: Sequence[Any], kwargs: Mapping[str, Any] ) -> Dict[str, Any]: - """Return mapping from parameter names to actual argument values""" + """Return mapping from parameter names to actual argument values.""" signature = inspect.signature(func) diff --git a/great_ai/models/__init__.py b/great_ai/models/__init__.py index ec4cda1..e69de29 100644 --- a/great_ai/models/__init__.py +++ b/great_ai/models/__init__.py @@ -1,2 +0,0 @@ -from .save_model import save_model -from .use_model import model_versions, use_model diff --git a/great_ai/models/save_model.py b/great_ai/models/save_model.py index 2b7049b..84bef03 100644 --- a/great_ai/models/save_model.py +++ b/great_ai/models/save_model.py @@ -19,7 +19,7 @@ def save_model( >>> from great_ai import use_model >>> save_model(3, 'my_number') 'my_number:...' - + >>> @use_model('my_number') ... def my_function(a, model): ... return a + model diff --git a/great_ai/models/use_model.py b/great_ai/models/use_model.py index 685fb52..f5e90c1 100644 --- a/great_ai/models/use_model.py +++ b/great_ai/models/use_model.py @@ -32,17 +32,13 @@ def use_model( ) -> Callable[[F], F]: """Inject a model into a function. - Load a model specified by `key` and `version` using the - currently active `LargeFile` implementation. If it's a - single object, it is deserialised using `dill`. If it's - a directory of files, a `pathlib.Path` instance is given. + Load a model specified by `key` and `version` using the currently active `LargeFile` + implementation. If it's a single object, it is deserialised using `dill`. If it's a + directory of files, a `pathlib.Path` instance is given. - By default, the function's `model` parameter is replaced - by the loaded model. This can be customised by changing - `model_kwarg_name`. - - Multiple models can be loaded by decorating the same - function with `use_model` multiple times. + By default, the function's `model` parameter is replaced by the loaded model. This + can be customised by changing `model_kwarg_name`. Multiple models can be loaded by + decorating the same function with `use_model` multiple times. Examples: >>> from great_ai import save_model diff --git a/great_ai/views/__init__.py b/great_ai/views/__init__.py index cf82c4f..3c66933 100644 --- a/great_ai/views/__init__.py +++ b/great_ai/views/__init__.py @@ -6,6 +6,11 @@ from .function_metadata import FunctionMetadata from .health_check_response import HealthCheckResponse from .model import Model from .operators import operators +from .outputs import ( + ClassificationOutput, + MultiLabelClassificationOutput, + RegressionOutput, +) from .query import Query from .route_config import RouteConfig from .sort_by import SortBy diff --git a/great_ai/helper/hashable_base_model.py b/great_ai/views/hashable_base_model.py similarity index 100% rename from great_ai/helper/hashable_base_model.py rename to great_ai/views/hashable_base_model.py diff --git a/great_ai/output_views/__init__.py b/great_ai/views/outputs/__init__.py similarity index 100% rename from great_ai/output_views/__init__.py rename to great_ai/views/outputs/__init__.py diff --git a/great_ai/output_views/classification_output.py b/great_ai/views/outputs/classification_output.py similarity index 76% rename from great_ai/output_views/classification_output.py rename to great_ai/views/outputs/classification_output.py index 6956aa4..f955cc2 100644 --- a/great_ai/output_views/classification_output.py +++ b/great_ai/views/outputs/classification_output.py @@ -1,6 +1,6 @@ from typing import Any, Optional, Union -from ..helper import HashableBaseModel +from ..hashable_base_model import HashableBaseModel class ClassificationOutput(HashableBaseModel): diff --git a/great_ai/output_views/multi_label_classification_output.py b/great_ai/views/outputs/multi_label_classification_output.py similarity index 77% rename from great_ai/output_views/multi_label_classification_output.py rename to great_ai/views/outputs/multi_label_classification_output.py index 52108c6..052e359 100644 --- a/great_ai/output_views/multi_label_classification_output.py +++ b/great_ai/views/outputs/multi_label_classification_output.py @@ -1,6 +1,6 @@ from typing import List -from ..helper import HashableBaseModel +from ..hashable_base_model import HashableBaseModel from .classification_output import ClassificationOutput diff --git a/great_ai/output_views/regression_output.py b/great_ai/views/outputs/regression_output.py similarity index 73% rename from great_ai/output_views/regression_output.py rename to great_ai/views/outputs/regression_output.py index 058ea75..96c1daf 100644 --- a/great_ai/output_views/regression_output.py +++ b/great_ai/views/outputs/regression_output.py @@ -1,6 +1,6 @@ from typing import Any, Optional, Union -from ..helper import HashableBaseModel +from ..hashable_base_model import HashableBaseModel class RegressionOutput(HashableBaseModel): diff --git a/great_ai/output_views/sequence_labeling_output.py b/great_ai/views/outputs/sequence_labeling_output.py similarity index 100% rename from great_ai/output_views/sequence_labeling_output.py rename to great_ai/views/outputs/sequence_labeling_output.py diff --git a/great_ai/views/trace.py b/great_ai/views/trace.py index 2e76e20..429a940 100644 --- a/great_ai/views/trace.py +++ b/great_ai/views/trace.py @@ -3,7 +3,7 @@ from typing import Any, Dict, Generic, List, Optional, TypeVar from pydantic import Extra -from ..helper import HashableBaseModel +from .hashable_base_model import HashableBaseModel from .model import Model T = TypeVar("T")