Move files
This commit is contained in:
parent
d2af1b8151
commit
f160b07163
159 changed files with 104 additions and 88 deletions
|
|
@ -14,12 +14,13 @@ from uvicorn.supervisors.basereload import BaseReload
|
||||||
from watchdog.events import FileSystemEvent, PatternMatchingEventHandler
|
from watchdog.events import FileSystemEvent, PatternMatchingEventHandler
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
|
|
||||||
|
from utilities import get_logger
|
||||||
|
|
||||||
from .great_ai.constants import SERVER_NAME
|
from .great_ai.constants import SERVER_NAME
|
||||||
from .great_ai.context import _is_in_production_mode
|
from .great_ai.context import _is_in_production_mode
|
||||||
from .great_ai.deploy import GreatAI
|
from .great_ai.deploy import GreatAI
|
||||||
from .great_ai.exceptions import ArgumentValidationError, MissingArgumentError
|
from .great_ai.exceptions import ArgumentValidationError, MissingArgumentError
|
||||||
from .parse_arguments import parse_arguments
|
from .parse_arguments import parse_arguments
|
||||||
from .utilities import get_logger
|
|
||||||
|
|
||||||
logger = get_logger(SERVER_NAME)
|
logger = get_logger(SERVER_NAME)
|
||||||
|
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
from .great_ai import *
|
from .context import configure
|
||||||
from .large_file import *
|
from .deploy import GreatAI
|
||||||
from .utilities import *
|
from .exceptions import (
|
||||||
|
ArgumentValidationError,
|
||||||
|
MissingArgumentError,
|
||||||
|
WrongDecoratorOrderError,
|
||||||
|
)
|
||||||
|
from .models import save_model, use_model
|
||||||
|
from .output_views import (
|
||||||
|
ClassificationOutput,
|
||||||
|
MultiLabelClassificationOutput,
|
||||||
|
RegressionOutput,
|
||||||
|
)
|
||||||
|
from .parameters import log_metric, parameter
|
||||||
|
from .persistence import MongodbDriver, ParallelTinyDbDriver, TracingDatabaseDriver
|
||||||
|
from .remote import (
|
||||||
|
HttpClient,
|
||||||
|
RemoteCallError,
|
||||||
|
call_remote_great_ai,
|
||||||
|
call_remote_great_ai_async,
|
||||||
|
)
|
||||||
|
from .tracing import add_ground_truth, delete_ground_truth, query_ground_truth
|
||||||
|
from .views import Trace
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from ..large_file import LargeFileMongo, LargeFileS3
|
from large_file import LargeFileMongo, LargeFileS3
|
||||||
|
|
||||||
from .persistence.mongodb_driver import MongodbDriver
|
from .persistence.mongodb_driver import MongodbDriver
|
||||||
|
|
||||||
ENV_VAR_KEY = "ENVIRONMENT"
|
ENV_VAR_KEY = "ENVIRONMENT"
|
||||||
|
|
@ -6,8 +6,9 @@ from typing import Any, Dict, Optional, Type, cast
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ..large_file import LargeFile, LargeFileLocal
|
from large_file import LargeFileBase, LargeFileLocal
|
||||||
from ..utilities import get_logger
|
from utilities import get_logger
|
||||||
|
|
||||||
from .constants import (
|
from .constants import (
|
||||||
DEFAULT_LARGE_FILE_CONFIG_PATHS,
|
DEFAULT_LARGE_FILE_CONFIG_PATHS,
|
||||||
DEFAULT_TRACING_DATABASE_CONFIG_PATHS,
|
DEFAULT_TRACING_DATABASE_CONFIG_PATHS,
|
||||||
|
|
@ -21,7 +22,7 @@ from .persistence import ParallelTinyDbDriver, TracingDatabaseDriver
|
||||||
|
|
||||||
class Context(BaseModel):
|
class Context(BaseModel):
|
||||||
tracing_database: TracingDatabaseDriver
|
tracing_database: TracingDatabaseDriver
|
||||||
large_file_implementation: Type[LargeFile]
|
large_file_implementation: Type[LargeFileBase]
|
||||||
is_production: bool
|
is_production: bool
|
||||||
logger: Logger
|
logger: Logger
|
||||||
should_log_exception_stack: bool
|
should_log_exception_stack: bool
|
||||||
|
|
@ -57,7 +58,7 @@ def configure(
|
||||||
log_level: int = DEBUG,
|
log_level: int = DEBUG,
|
||||||
seed: int = 42,
|
seed: int = 42,
|
||||||
tracing_database: Optional[Type[TracingDatabaseDriver]] = None,
|
tracing_database: Optional[Type[TracingDatabaseDriver]] = None,
|
||||||
large_file_implementation: Optional[Type[LargeFile]] = None,
|
large_file_implementation: Optional[Type[LargeFileBase]] = None,
|
||||||
should_log_exception_stack: Optional[bool] = None,
|
should_log_exception_stack: Optional[bool] = None,
|
||||||
prediction_cache_size: int = 512,
|
prediction_cache_size: int = 512,
|
||||||
disable_se4ml_banner: bool = False,
|
disable_se4ml_banner: bool = False,
|
||||||
|
|
@ -160,8 +161,8 @@ def _initialize_tracing_database(
|
||||||
|
|
||||||
|
|
||||||
def _initialize_large_file(
|
def _initialize_large_file(
|
||||||
selected: Optional[Type[LargeFile]], logger: Logger
|
selected: Optional[Type[LargeFileBase]], logger: Logger
|
||||||
) -> Type[LargeFile]:
|
) -> Type[LargeFileBase]:
|
||||||
for large_file, paths in DEFAULT_LARGE_FILE_CONFIG_PATHS.items():
|
for large_file, paths in DEFAULT_LARGE_FILE_CONFIG_PATHS.items():
|
||||||
if selected is None or selected == large_file:
|
if selected is None or selected == large_file:
|
||||||
if large_file.initialized:
|
if large_file.initialized:
|
||||||
|
|
@ -16,7 +16,8 @@ from typing import (
|
||||||
from fastapi import APIRouter, FastAPI, status
|
from fastapi import APIRouter, FastAPI, status
|
||||||
from pydantic import BaseModel, create_model
|
from pydantic import BaseModel, create_model
|
||||||
|
|
||||||
from ...utilities import parallel_map
|
from utilities import parallel_map
|
||||||
|
|
||||||
from ..constants import DASHBOARD_PATH
|
from ..constants import DASHBOARD_PATH
|
||||||
from ..context import get_context
|
from ..context import get_context
|
||||||
from ..helper import (
|
from ..helper import (
|
||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
|
@ -8,7 +8,8 @@ from dash import Dash, dcc, html
|
||||||
from dash.dependencies import Input, Output
|
from dash.dependencies import Input, Output
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from .....utilities import unique
|
from utilities import unique
|
||||||
|
|
||||||
from ....constants import DASHBOARD_PATH, ONLINE_TAG_NAME
|
from ....constants import DASHBOARD_PATH, ONLINE_TAG_NAME
|
||||||
from ....context import get_context
|
from ....context import get_context
|
||||||
from ....helper import freeze, snake_case_to_text, text_to_hex_color
|
from ....helper import freeze, snake_case_to_text, text_to_hex_color
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
from .context import configure
|
|
||||||
from .deploy import GreatAI
|
|
||||||
from .exceptions import (
|
|
||||||
ArgumentValidationError,
|
|
||||||
MissingArgumentError,
|
|
||||||
WrongDecoratorOrderError,
|
|
||||||
)
|
|
||||||
from .models import save_model, use_model
|
|
||||||
from .output_views import (
|
|
||||||
ClassificationOutput,
|
|
||||||
MultiLabelClassificationOutput,
|
|
||||||
RegressionOutput,
|
|
||||||
)
|
|
||||||
from .parameters import log_metric, parameter
|
|
||||||
from .persistence import MongodbDriver, ParallelTinyDbDriver, TracingDatabaseDriver
|
|
||||||
from .remote import (
|
|
||||||
HttpClient,
|
|
||||||
RemoteCallError,
|
|
||||||
call_remote_great_ai,
|
|
||||||
call_remote_great_ai_async,
|
|
||||||
)
|
|
||||||
from .tracing import add_ground_truth, delete_ground_truth, query_ground_truth
|
|
||||||
from .views import Trace
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
from .large_file import LargeFile, LargeFileLocal, LargeFileMongo, LargeFileS3
|
|
||||||
|
|
@ -3,7 +3,8 @@ from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional, Sequence, Tuple, Union
|
from typing import List, Optional, Sequence, Tuple, Union
|
||||||
|
|
||||||
from ...utilities import ConfigFile
|
from utilities import ConfigFile
|
||||||
|
|
||||||
from ..views import Filter, SortBy, Trace
|
from ..views import Filter, SortBy, Trace
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,7 +3,8 @@ from typing import Any, Mapping, Optional, Type, TypeVar
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ...utilities import get_logger
|
from utilities import get_logger
|
||||||
|
|
||||||
from ..views import Trace
|
from ..views import Trace
|
||||||
from .call_remote_great_ai_async import call_remote_great_ai_async
|
from .call_remote_great_ai_async import call_remote_great_ai_async
|
||||||
|
|
||||||
0
src/great_ai/utilities/external/__init__.py
vendored
0
src/great_ai/utilities/external/__init__.py
vendored
|
|
@ -1,16 +0,0 @@
|
||||||
from typing import Any, Callable, Iterable, List
|
|
||||||
|
|
||||||
|
|
||||||
def unique(
|
|
||||||
values: Iterable[Any], *, key: Callable[[Any], Any] = lambda v: v
|
|
||||||
) -> List[Any]:
|
|
||||||
"""Only keep first occurrences and maintain order"""
|
|
||||||
|
|
||||||
key_values = {}
|
|
||||||
for v in values:
|
|
||||||
k = key(v)
|
|
||||||
if k not in key_values:
|
|
||||||
# dicts maintain insertion order: https://mail.python.org/pipermail/python-dev/2017-December/151283.html
|
|
||||||
key_values[k] = v
|
|
||||||
|
|
||||||
return list(key_values.values())
|
|
||||||
1
src/large_file/__init__.py
Normal file
1
src/large_file/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from .large_file import LargeFileBase, LargeFileLocal, LargeFileMongo, LargeFileS3
|
||||||
|
|
@ -4,8 +4,9 @@ from argparse import Namespace
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Mapping, Type
|
from typing import Mapping, Type
|
||||||
|
|
||||||
from ..utilities import get_logger
|
from large_file import LargeFileBase, LargeFileLocal, LargeFileMongo, LargeFileS3
|
||||||
from .large_file import LargeFile, LargeFileLocal, LargeFileMongo, LargeFileS3
|
from utilities import get_logger
|
||||||
|
|
||||||
from .parse_arguments import parse_arguments
|
from .parse_arguments import parse_arguments
|
||||||
|
|
||||||
logger = get_logger("large_file")
|
logger = get_logger("large_file")
|
||||||
|
|
@ -37,8 +38,8 @@ def main() -> None:
|
||||||
large_file(f).delete()
|
large_file(f).delete()
|
||||||
|
|
||||||
|
|
||||||
def get_class(args: Namespace) -> Type[LargeFile]:
|
def get_class(args: Namespace) -> Type[LargeFileBase]:
|
||||||
factory: Mapping[str, Type[LargeFile]] = {
|
factory: Mapping[str, Type[LargeFileBase]] = {
|
||||||
"s3": LargeFileS3,
|
"s3": LargeFileS3,
|
||||||
"local": LargeFileLocal,
|
"local": LargeFileLocal,
|
||||||
"mongodb": LargeFileMongo,
|
"mongodb": LargeFileMongo,
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from .large_file import LargeFile
|
from .large_file_base import LargeFileBase
|
||||||
from .large_file_local import LargeFileLocal
|
from .large_file_local import LargeFileLocal
|
||||||
from .large_file_mongo import LargeFileMongo
|
from .large_file_mongo import LargeFileMongo
|
||||||
from .large_file_s3 import LargeFileS3
|
from .large_file_s3 import LargeFileS3
|
||||||
|
|
@ -7,7 +7,8 @@ from pathlib import Path
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import IO, Any, List, Optional, Type, Union, cast
|
from typing import IO, Any, List, Optional, Type, Union, cast
|
||||||
|
|
||||||
from ...utilities import ConfigFile, get_logger
|
from utilities import ConfigFile, get_logger
|
||||||
|
|
||||||
from ..helper import human_readable_to_byte
|
from ..helper import human_readable_to_byte
|
||||||
from ..models import DataInstance
|
from ..models import DataInstance
|
||||||
|
|
||||||
|
|
@ -19,7 +20,7 @@ COMPRESSION_ALGORITHM = "gztar"
|
||||||
ARCHIVE_EXTENSION = ".tar.gz"
|
ARCHIVE_EXTENSION = ".tar.gz"
|
||||||
|
|
||||||
|
|
||||||
class LargeFile(ABC):
|
class LargeFileBase(ABC):
|
||||||
"""
|
"""
|
||||||
Store large files remotely. Use local cache for speed up.
|
Store large files remotely. Use local cache for speed up.
|
||||||
|
|
||||||
|
|
@ -75,7 +76,7 @@ class LargeFile(ABC):
|
||||||
self._errors = errors
|
self._errors = errors
|
||||||
self._newline = newline
|
self._newline = newline
|
||||||
|
|
||||||
LargeFile.cache_path.mkdir(parents=True, exist_ok=True)
|
LargeFileBase.cache_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
self._find_instances()
|
self._find_instances()
|
||||||
self._check_mode_and_set_version()
|
self._check_mode_and_set_version()
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, List, Optional
|
from typing import Any, List, Optional
|
||||||
|
|
||||||
from ...utilities import get_logger
|
from utilities import get_logger
|
||||||
|
|
||||||
from ..models import DataInstance
|
from ..models import DataInstance
|
||||||
from .large_file import LargeFile
|
from .large_file_base import LargeFileBase
|
||||||
|
|
||||||
logger = get_logger("large_file")
|
logger = get_logger("large_file")
|
||||||
|
|
||||||
|
|
||||||
class LargeFileLocal(LargeFile):
|
class LargeFileLocal(LargeFileBase):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
|
|
@ -6,10 +6,11 @@ from typing import Any, List, Mapping
|
||||||
from gridfs import DEFAULT_CHUNK_SIZE, Database, GridFSBucket
|
from gridfs import DEFAULT_CHUNK_SIZE, Database, GridFSBucket
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
|
||||||
from ...utilities import get_logger
|
from utilities import get_logger
|
||||||
|
|
||||||
from ..helper import DownloadProgressBar, UploadProgressBar
|
from ..helper import DownloadProgressBar, UploadProgressBar
|
||||||
from ..models import DataInstance
|
from ..models import DataInstance
|
||||||
from .large_file import LargeFile
|
from .large_file_base import LargeFileBase
|
||||||
|
|
||||||
logger = get_logger("large_file")
|
logger = get_logger("large_file")
|
||||||
|
|
||||||
|
|
@ -17,7 +18,7 @@ logger = get_logger("large_file")
|
||||||
MONGO_NAME_VERSION_SEPARATOR = "_"
|
MONGO_NAME_VERSION_SEPARATOR = "_"
|
||||||
|
|
||||||
|
|
||||||
class LargeFileMongo(LargeFile):
|
class LargeFileMongo(LargeFileBase):
|
||||||
mongo_connection_string = None
|
mongo_connection_string = None
|
||||||
mongo_database = None
|
mongo_database = None
|
||||||
|
|
||||||
|
|
@ -4,10 +4,11 @@ from typing import Any, List, Mapping, Optional
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
|
||||||
from ...utilities import get_logger
|
from utilities import get_logger
|
||||||
|
|
||||||
from ..helper import DownloadProgressBar, UploadProgressBar
|
from ..helper import DownloadProgressBar, UploadProgressBar
|
||||||
from ..models import DataInstance
|
from ..models import DataInstance
|
||||||
from .large_file import LargeFile
|
from .large_file_base import LargeFileBase
|
||||||
|
|
||||||
logger = get_logger("large_file")
|
logger = get_logger("large_file")
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ logger = get_logger("large_file")
|
||||||
S3_NAME_VERSION_SEPARATOR = "/"
|
S3_NAME_VERSION_SEPARATOR = "/"
|
||||||
|
|
||||||
|
|
||||||
class LargeFileS3(LargeFile):
|
class LargeFileS3(LargeFileBase):
|
||||||
"""
|
"""
|
||||||
Store large files in S3. Use local cache for speed up.
|
Store large files in S3. Use local cache for speed up.
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue