qwak-core 0.4.266__py3-none-any.whl → 0.4.267__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qwak/__init__.py +1 -1
- qwak/clients/instance_template/client.py +4 -6
- qwak/clients/prompt_manager/model_descriptor_mapper.py +19 -21
- qwak/feature_store/_common/artifact_utils.py +3 -3
- qwak/feature_store/data_sources/base.py +4 -4
- qwak/feature_store/data_sources/batch/athena.py +3 -3
- qwak/feature_store/feature_sets/streaming.py +3 -3
- qwak/feature_store/feature_sets/streaming_backfill.py +1 -1
- qwak/feature_store/online/client.py +6 -6
- qwak/feature_store/sinks/streaming/factory.py +1 -1
- qwak/inner/build_logic/phases/phase_010_fetch_model/fetch_strategy_manager/strategy/git/git_strategy.py +3 -3
- qwak/llmops/provider/openai/provider.py +3 -3
- qwak/model/tools/adapters/output.py +1 -1
- qwak/model/utils/feature_utils.py +8 -12
- qwak/model_loggers/artifact_logger.py +7 -7
- qwak/tools/logger/logger.py +1 -1
- qwak_core-0.4.267.dist-info/METADATA +53 -0
- {qwak_core-0.4.266.dist-info → qwak_core-0.4.267.dist-info}/RECORD +19 -51
- frogml_storage/__init__.py +0 -0
- frogml_storage/_artifactory_api.py +0 -315
- frogml_storage/_environment.py +0 -22
- frogml_storage/_log_config.py +0 -45
- frogml_storage/_storage_utils.py +0 -15
- frogml_storage/_utils.py +0 -69
- frogml_storage/authentication/_authentication_utils.py +0 -259
- frogml_storage/authentication/models/_auth_config.py +0 -70
- frogml_storage/cli/_frogml_cli.py +0 -40
- frogml_storage/cli/_login_cli.py +0 -240
- frogml_storage/cli/commands/_login_command.py +0 -74
- frogml_storage/cli/models/_cli_login_arguments.py +0 -22
- frogml_storage/cli/utils/_cli_utils.py +0 -19
- frogml_storage/cli/utils/_login_checks_utility.py +0 -114
- frogml_storage/constants.py +0 -56
- frogml_storage/dataset_manifest.py +0 -13
- frogml_storage/entity_manifest.py +0 -93
- frogml_storage/exceptions/checksum_verification_error.py +0 -3
- frogml_storage/exceptions/validation_error.py +0 -4
- frogml_storage/frog_ml.py +0 -668
- frogml_storage/frogml_entity_type_info.py +0 -46
- frogml_storage/http/__init__.py +0 -0
- frogml_storage/http/http_client.py +0 -83
- frogml_storage/model_manifest.py +0 -60
- frogml_storage/models/_download_context.py +0 -54
- frogml_storage/models/frogml_dataset_version.py +0 -21
- frogml_storage/models/frogml_entity_version.py +0 -34
- frogml_storage/models/frogml_model_version.py +0 -21
- frogml_storage/serialization_metadata.py +0 -15
- frogml_storage/storage.py +0 -140
- frogml_storage/utils/_input_checks_utility.py +0 -104
- qwak_core-0.4.266.dist-info/METADATA +0 -419
- qwak_core-0.4.266.dist-info/entry_points.txt +0 -3
- {qwak_core-0.4.266.dist-info → qwak_core-0.4.267.dist-info}/WHEEL +0 -0
frogml_storage/http/__init__.py
DELETED
File without changes
|
@@ -1,83 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from typing import Optional, Tuple
|
3
|
-
|
4
|
-
import requests
|
5
|
-
from requests.adapters import HTTPAdapter
|
6
|
-
from urllib3 import Retry
|
7
|
-
|
8
|
-
import qwak
|
9
|
-
from frogml_storage._log_config import logger
|
10
|
-
|
11
|
-
|
12
|
-
class HTTPClient:
|
13
|
-
|
14
|
-
def __init__(
|
15
|
-
self, auth: Tuple[str, str], session: Optional[requests.Session] = None
|
16
|
-
):
|
17
|
-
self.auth = auth
|
18
|
-
# add default headers
|
19
|
-
if session is None:
|
20
|
-
self.session = self._create_session()
|
21
|
-
self._add_default_headers()
|
22
|
-
self.timeout = os.getenv("JFML_TIMEOUT", default=30)
|
23
|
-
|
24
|
-
@staticmethod
|
25
|
-
def _create_session():
|
26
|
-
session = requests.Session()
|
27
|
-
adapter = HTTPAdapter(
|
28
|
-
max_retries=RetryWithLog(
|
29
|
-
total=5, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504]
|
30
|
-
)
|
31
|
-
)
|
32
|
-
session.mount("http://", adapter)
|
33
|
-
session.mount("https://", adapter)
|
34
|
-
return session
|
35
|
-
|
36
|
-
def post(self, url, data=None, params=None):
|
37
|
-
return self.session.post(
|
38
|
-
url, auth=self.auth, timeout=self.timeout, data=data, params=params
|
39
|
-
)
|
40
|
-
|
41
|
-
def get(self, url, params=None, stream=False):
|
42
|
-
return self.session.get(url, auth=self.auth, params=params, stream=stream)
|
43
|
-
|
44
|
-
def put(self, url, payload=None, files=None, stream=False, headers=None, json=None):
|
45
|
-
return self.session.request(
|
46
|
-
method="PUT",
|
47
|
-
url=url,
|
48
|
-
data=payload,
|
49
|
-
auth=self.auth,
|
50
|
-
files=files,
|
51
|
-
stream=stream,
|
52
|
-
timeout=self.timeout,
|
53
|
-
headers=headers,
|
54
|
-
json=json,
|
55
|
-
)
|
56
|
-
|
57
|
-
def delete(self, url):
|
58
|
-
return self.session.request(
|
59
|
-
method="DELETE",
|
60
|
-
url=url,
|
61
|
-
auth=self.auth,
|
62
|
-
timeout=self.timeout,
|
63
|
-
)
|
64
|
-
|
65
|
-
def head(self, url, params=None, stream=False):
|
66
|
-
return self.session.head(url, auth=self.auth, params=params, stream=stream)
|
67
|
-
|
68
|
-
def _add_default_headers(self):
|
69
|
-
self.session.headers.update(
|
70
|
-
{"User-Agent": "frogml-sdk-python/{}".format(qwak.__version__)}
|
71
|
-
)
|
72
|
-
|
73
|
-
|
74
|
-
class RetryWithLog(Retry):
|
75
|
-
"""
|
76
|
-
Adding extra logs before making a retry request
|
77
|
-
"""
|
78
|
-
|
79
|
-
def __init__(self, *args, **kwargs):
|
80
|
-
history = kwargs.get("history")
|
81
|
-
if history is not None:
|
82
|
-
logger.debug(f"Error: ${history[-1].error}\nretrying...")
|
83
|
-
super().__init__(*args, **kwargs)
|
frogml_storage/model_manifest.py
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from typing import List, Optional
|
3
|
-
|
4
|
-
from pydantic import ConfigDict, Field
|
5
|
-
|
6
|
-
from frogml_storage.entity_manifest import Artifact, Checksums, EntityManifest
|
7
|
-
from frogml_storage.serialization_metadata import SerializationMetadata
|
8
|
-
|
9
|
-
|
10
|
-
class ModelManifest(EntityManifest):
|
11
|
-
"""
|
12
|
-
Represent a model manifest file
|
13
|
-
|
14
|
-
Attributes:
|
15
|
-
model_format: If the entity is model, holds model format information
|
16
|
-
dependency_artifacts: If the entity is model, holds a list of files specifying the model dependencies
|
17
|
-
code_artifacts: If the entity is model, specifies the archive file artifact
|
18
|
-
"""
|
19
|
-
|
20
|
-
artifacts: List[Artifact] = Field(serialization_alias="model_artifacts")
|
21
|
-
|
22
|
-
model_format: SerializationMetadata
|
23
|
-
dependency_artifacts: Optional[List[Artifact]] = None
|
24
|
-
code_artifacts: Optional[Artifact] = None
|
25
|
-
|
26
|
-
# suppress warning on model_format field name.
|
27
|
-
# if one day it collides with pydantic field, it will throw an error.
|
28
|
-
model_config = ConfigDict(protected_namespaces=())
|
29
|
-
|
30
|
-
def add_dependency_file(
|
31
|
-
self, file_path: str, checksums: Checksums, rel_path: str
|
32
|
-
) -> None:
|
33
|
-
if self.dependency_artifacts is None:
|
34
|
-
self.dependency_artifacts = []
|
35
|
-
self.dependency_artifacts.append(
|
36
|
-
Artifact(
|
37
|
-
artifact_path=rel_path,
|
38
|
-
size=os.path.getsize(file_path),
|
39
|
-
checksums=checksums,
|
40
|
-
)
|
41
|
-
)
|
42
|
-
|
43
|
-
def __eq__(self, other):
|
44
|
-
if not super.__eq__(self, other):
|
45
|
-
return False
|
46
|
-
if self.model_format != other.model_format:
|
47
|
-
return False
|
48
|
-
if self.dependency_artifacts != other.dependency_artifacts:
|
49
|
-
return False
|
50
|
-
if self.dependency_artifacts is not None:
|
51
|
-
if len(self.dependency_artifacts) != len(other.dependency_artifacts):
|
52
|
-
return False
|
53
|
-
for self_artifact, other_artifact in zip(
|
54
|
-
self.dependency_artifacts, other.dependency_artifacts
|
55
|
-
):
|
56
|
-
if self_artifact != other_artifact:
|
57
|
-
return False
|
58
|
-
if self.code_artifacts != other.code_artifacts:
|
59
|
-
return False
|
60
|
-
return True
|
@@ -1,54 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from frogml_storage.entity_manifest import Checksums
|
4
|
-
|
5
|
-
|
6
|
-
class DownloadContext(object):
|
7
|
-
"""
|
8
|
-
A class to represent the arguments for a download operation.
|
9
|
-
|
10
|
-
Attributes
|
11
|
-
----------
|
12
|
-
repo_key : str
|
13
|
-
The key of the repository where the artifact is located.
|
14
|
-
source_url : str
|
15
|
-
The source relative URL of the artifact, relative to artifactory url and the repo key.
|
16
|
-
target_path : str
|
17
|
-
The target path where the artifact will be downloaded to.
|
18
|
-
exists_locally : bool
|
19
|
-
A flag indicating whether the artifact already exists locally in the target path.
|
20
|
-
artifact_checksum: Checksums
|
21
|
-
The checksum of the artifact.
|
22
|
-
"""
|
23
|
-
|
24
|
-
repo_key: str
|
25
|
-
source_url: str
|
26
|
-
target_path: str
|
27
|
-
exists_locally: bool = False
|
28
|
-
artifact_checksum: Optional[Checksums]
|
29
|
-
|
30
|
-
def __init__(
|
31
|
-
self,
|
32
|
-
repo_key: str,
|
33
|
-
source_url: str,
|
34
|
-
target_path: str,
|
35
|
-
exists_locally: bool = False,
|
36
|
-
artifact_checksum: Optional[Checksums] = None,
|
37
|
-
):
|
38
|
-
self.repo_key = repo_key
|
39
|
-
self.source_url = source_url
|
40
|
-
self.target_path = target_path
|
41
|
-
self.exists_locally = exists_locally
|
42
|
-
self.artifact_checksum = artifact_checksum
|
43
|
-
|
44
|
-
def __eq__(self, other):
|
45
|
-
if not isinstance(other, DownloadContext):
|
46
|
-
return False
|
47
|
-
|
48
|
-
return (
|
49
|
-
self.repo_key == other.repo_key
|
50
|
-
and self.source_url == other.source_url
|
51
|
-
and self.target_path == other.target_path
|
52
|
-
and self.exists_locally == other.exists_locally
|
53
|
-
and self.artifact_checksum == other.artifact_checksum
|
54
|
-
)
|
@@ -1,21 +0,0 @@
|
|
1
|
-
from frogml_storage.models.frogml_entity_version import FrogMLEntityVersion
|
2
|
-
|
3
|
-
|
4
|
-
class FrogMLDatasetVersion(FrogMLEntityVersion):
|
5
|
-
"""
|
6
|
-
Represent metadata of an uploaded dataset version.
|
7
|
-
|
8
|
-
Inherits:
|
9
|
-
FrogMLEntityVersion: Base class for entity versions.
|
10
|
-
"""
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def from_entity_version(
|
14
|
-
cls, entity_version: FrogMLEntityVersion
|
15
|
-
) -> "FrogMLDatasetVersion":
|
16
|
-
return cls(
|
17
|
-
entity_name=entity_version.entity_name,
|
18
|
-
version=entity_version.version,
|
19
|
-
namespace=entity_version.namespace,
|
20
|
-
entity_manifest=entity_version.entity_manifest,
|
21
|
-
)
|
@@ -1,34 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from pydantic import BaseModel
|
4
|
-
|
5
|
-
from frogml_storage.entity_manifest import EntityManifest
|
6
|
-
|
7
|
-
|
8
|
-
class FrogMLEntityVersion(BaseModel):
|
9
|
-
"""
|
10
|
-
Represent a metadata of uploaded entity
|
11
|
-
|
12
|
-
Attributes:
|
13
|
-
entity_name: The entity name (model | dataset)
|
14
|
-
namespace: The namespace of the model | dataset
|
15
|
-
version: The version of the model | dataset
|
16
|
-
entity_manifest: The entity manifest file
|
17
|
-
"""
|
18
|
-
|
19
|
-
entity_name: str
|
20
|
-
namespace: Optional[str] = None
|
21
|
-
version: str
|
22
|
-
entity_manifest: Optional[EntityManifest] = None
|
23
|
-
|
24
|
-
def __eq__(self, other):
|
25
|
-
if not isinstance(other, FrogMLEntityVersion):
|
26
|
-
return False
|
27
|
-
if self.version != other.version:
|
28
|
-
return False
|
29
|
-
if self.namespace != other.namespace:
|
30
|
-
return False
|
31
|
-
if self.entity_name != other.entity_name:
|
32
|
-
return False
|
33
|
-
|
34
|
-
return True
|
@@ -1,21 +0,0 @@
|
|
1
|
-
from frogml_storage.models.frogml_entity_version import FrogMLEntityVersion
|
2
|
-
|
3
|
-
|
4
|
-
class FrogMLModelVersion(FrogMLEntityVersion):
|
5
|
-
"""
|
6
|
-
Represent metadata of an uploaded model version.
|
7
|
-
|
8
|
-
Inherits:
|
9
|
-
FrogMLEntityVersion: Base class for entity versions.
|
10
|
-
"""
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def from_entity_version(
|
14
|
-
cls, entity_version: FrogMLEntityVersion
|
15
|
-
) -> "FrogMLModelVersion":
|
16
|
-
return cls(
|
17
|
-
entity_name=entity_version.entity_name,
|
18
|
-
version=entity_version.version,
|
19
|
-
namespace=entity_version.namespace,
|
20
|
-
entity_manifest=entity_version.entity_manifest,
|
21
|
-
)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
|
-
from pydantic import BaseModel
|
4
|
-
|
5
|
-
|
6
|
-
class SerializationMetadata(BaseModel):
|
7
|
-
framework: str
|
8
|
-
framework_version: str
|
9
|
-
serialization_format: str
|
10
|
-
runtime: str
|
11
|
-
runtime_version: str
|
12
|
-
|
13
|
-
@classmethod
|
14
|
-
def from_json(cls, json_dict: Dict) -> "SerializationMetadata":
|
15
|
-
return cls.model_validate(json_dict)
|
frogml_storage/storage.py
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
from abc import ABC, abstractmethod
|
2
|
-
from typing import Dict, List, Optional, Union
|
3
|
-
|
4
|
-
from frogml_storage.models.frogml_dataset_version import FrogMLDatasetVersion
|
5
|
-
from frogml_storage.models.frogml_model_version import FrogMLModelVersion
|
6
|
-
from frogml_storage.serialization_metadata import SerializationMetadata
|
7
|
-
|
8
|
-
|
9
|
-
class Storage(ABC):
|
10
|
-
"""
|
11
|
-
Repository storage to download or store model | dataset artifacts,
|
12
|
-
metrics and relation between these in an Artifactory repository.
|
13
|
-
"""
|
14
|
-
|
15
|
-
@abstractmethod
|
16
|
-
def upload_model_version(
|
17
|
-
self,
|
18
|
-
repository: str,
|
19
|
-
model_name: str,
|
20
|
-
model_path: str,
|
21
|
-
model_type: Union[SerializationMetadata, Dict],
|
22
|
-
namespace: Optional[str] = None,
|
23
|
-
version: Optional[str] = None,
|
24
|
-
properties: Optional[dict[str, str]] = None,
|
25
|
-
dependencies_files_paths: Optional[List[str]] = None,
|
26
|
-
code_archive_file_path: Optional[str] = None,
|
27
|
-
) -> FrogMLModelVersion:
|
28
|
-
"""Upload model to a repository in Artifactory. Uploaded models should be stored with the following layout:
|
29
|
-
├── REPO
|
30
|
-
├── models
|
31
|
-
├── ${NAMESPACE}
|
32
|
-
├── ${MODEL_NAME}
|
33
|
-
├── ${MODEL_VERSION}
|
34
|
-
├── model-manifest.json
|
35
|
-
├── model
|
36
|
-
├── model.pkl
|
37
|
-
├── evidence.json
|
38
|
-
├── ...
|
39
|
-
├── code
|
40
|
-
├── code.zip
|
41
|
-
├── requirements.txt
|
42
|
-
:param repository: the repository to upload the model to
|
43
|
-
:param model_name: the name of the model
|
44
|
-
:param model_path: the source path of the model
|
45
|
-
:param model_type: the type of the model (PyTorch, HuggingFace, Catboost)
|
46
|
-
:param namespace: the namespace to upload the model to
|
47
|
-
:param version: the version of the model
|
48
|
-
:param properties: tags to associate with the model
|
49
|
-
:param dependencies_files_paths: the list of dependencies files paths
|
50
|
-
:param code_archive_file_path: the path to the code archive file
|
51
|
-
"""
|
52
|
-
pass
|
53
|
-
|
54
|
-
@abstractmethod
|
55
|
-
def download_model_version(
|
56
|
-
self,
|
57
|
-
repository: str,
|
58
|
-
model_name: str,
|
59
|
-
version: str,
|
60
|
-
target_path: str,
|
61
|
-
namespace: Optional[str] = None,
|
62
|
-
) -> None:
|
63
|
-
"""Downloads a model from an Artifactory repository
|
64
|
-
:param repository: the repository to download the model from
|
65
|
-
:param model_name: the name of the model to download
|
66
|
-
:param version: the version of the model to download
|
67
|
-
:param target_path: the target local path to store the model in
|
68
|
-
:param namespace: the namespace of the model to download
|
69
|
-
|
70
|
-
"""
|
71
|
-
pass
|
72
|
-
|
73
|
-
def download_model_single_artifact(
|
74
|
-
self,
|
75
|
-
repository: str,
|
76
|
-
model_name: str,
|
77
|
-
version: str,
|
78
|
-
target_path: str,
|
79
|
-
source_artifact_path: str,
|
80
|
-
namespace: Optional[str] = None,
|
81
|
-
) -> None:
|
82
|
-
"""Downloads an artifact from an Artifactory repository
|
83
|
-
:param repository: the repository to download the artifact from
|
84
|
-
:param model_name: the model to download artifact from
|
85
|
-
:param version: the model's version to download artifact from
|
86
|
-
:param target_path: the target local path to store the artifact in
|
87
|
-
:param source_artifact_path: the path of the artifact under the model's version directory
|
88
|
-
:param namespace: the namespace of the artifact
|
89
|
-
"""
|
90
|
-
pass
|
91
|
-
|
92
|
-
@abstractmethod
|
93
|
-
def upload_dataset_version(
|
94
|
-
self,
|
95
|
-
repository: str,
|
96
|
-
dataset_name: str,
|
97
|
-
source_path: str,
|
98
|
-
namespace: Optional[str] = None,
|
99
|
-
version: Optional[str] = None,
|
100
|
-
tags: Optional[dict[str, str]] = None,
|
101
|
-
) -> FrogMLDatasetVersion:
|
102
|
-
"""Uploads a dataset to a repository in Artifactory. Uploaded datasets should be stored with
|
103
|
-
the following layout:
|
104
|
-
├── REPO
|
105
|
-
├── datasets
|
106
|
-
├── ${NAMESPACE}
|
107
|
-
├── ${DATASET_NAME}
|
108
|
-
├── ${DATASET_VERSION}
|
109
|
-
├── dataset-manifest.json
|
110
|
-
├── dataset
|
111
|
-
├── cli_docs_1.csv
|
112
|
-
├── cli_docs_2.csv
|
113
|
-
├── ...
|
114
|
-
:param repository: the repository to upload the dataset to
|
115
|
-
:param dataset_name: the name of the dataset
|
116
|
-
:param source_path: the source path of the dataset
|
117
|
-
:param namespace: the namespace to upload the dataset to
|
118
|
-
:param version: the version of the dataset
|
119
|
-
:param tags: tags to associate with the dataset
|
120
|
-
"""
|
121
|
-
pass
|
122
|
-
|
123
|
-
@abstractmethod
|
124
|
-
def download_dataset_version(
|
125
|
-
self,
|
126
|
-
repository: str,
|
127
|
-
dataset_name: str,
|
128
|
-
version: str,
|
129
|
-
target_path: str,
|
130
|
-
namespace: Optional[str] = None,
|
131
|
-
) -> None:
|
132
|
-
"""Downloads a dataset from an Artifactory repository
|
133
|
-
:param repository: the repository to download the dataset from
|
134
|
-
:param dataset_name: the name of the dataset to download
|
135
|
-
:param version: the version of the dataset to download
|
136
|
-
:param target_path: the target local path to store the dataset in
|
137
|
-
:param namespace: the namespace of the dataset to download
|
138
|
-
|
139
|
-
"""
|
140
|
-
pass
|
@@ -1,104 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import re
|
3
|
-
from typing import List, Optional, Union
|
4
|
-
|
5
|
-
from frogml_storage._log_config import logger
|
6
|
-
from frogml_storage.constants import FROG_ML_MAX_CHARS_FOR_NAME
|
7
|
-
from frogml_storage.exceptions.validation_error import FrogMLValidationError
|
8
|
-
|
9
|
-
valid_characters_pattern = re.compile(r"^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*$")
|
10
|
-
|
11
|
-
|
12
|
-
def user_input_validation(
|
13
|
-
entity_name: Optional[str],
|
14
|
-
namespace: Optional[str],
|
15
|
-
version: Optional[str],
|
16
|
-
properties: Optional[dict[str, str]] = None,
|
17
|
-
) -> bool:
|
18
|
-
for arg_name, arg_value in {
|
19
|
-
"entity_name": entity_name,
|
20
|
-
"namespace": namespace,
|
21
|
-
"version": version,
|
22
|
-
}.items():
|
23
|
-
if arg_value is not None:
|
24
|
-
__input_validation(arg_value, arg_name)
|
25
|
-
|
26
|
-
if properties is not None:
|
27
|
-
__user_input_dict_validation(properties)
|
28
|
-
|
29
|
-
return True
|
30
|
-
|
31
|
-
|
32
|
-
def __user_input_dict_validation(properties: dict[str, str]) -> bool:
|
33
|
-
if properties is not None:
|
34
|
-
for key, value in properties.items():
|
35
|
-
__input_validation(key, "properties")
|
36
|
-
__input_validation(value, "properties")
|
37
|
-
return True
|
38
|
-
|
39
|
-
|
40
|
-
def is_not_none(arg_name: str, arg_value: Optional[object]) -> bool:
|
41
|
-
if arg_value is None:
|
42
|
-
raise FrogMLValidationError("{} can't be 'None'.".format(arg_name))
|
43
|
-
return True
|
44
|
-
|
45
|
-
|
46
|
-
def __input_validation(field_value: str, field_name: str) -> bool:
|
47
|
-
if len(str(field_value)) > FROG_ML_MAX_CHARS_FOR_NAME:
|
48
|
-
raise FrogMLValidationError(
|
49
|
-
"Max length for {} is 60 characters.".format(field_name.capitalize())
|
50
|
-
)
|
51
|
-
|
52
|
-
if not field_value or not re.match(valid_characters_pattern, str(field_value)):
|
53
|
-
raise FrogMLValidationError(
|
54
|
-
"Invalid characters detected at {}: {}".format(
|
55
|
-
field_name.capitalize(), field_value
|
56
|
-
)
|
57
|
-
)
|
58
|
-
|
59
|
-
return True
|
60
|
-
|
61
|
-
|
62
|
-
def is_valid_thread_number(thread_count: str) -> bool:
|
63
|
-
try:
|
64
|
-
int_thread_count = int(thread_count)
|
65
|
-
cpu_count = os.cpu_count()
|
66
|
-
if int_thread_count <= 0 or (
|
67
|
-
cpu_count is not None and int_thread_count >= cpu_count
|
68
|
-
):
|
69
|
-
raise ValueError(
|
70
|
-
"Invalid thread count: {}. The default value will be used.".format(
|
71
|
-
thread_count
|
72
|
-
)
|
73
|
-
)
|
74
|
-
return True
|
75
|
-
except ValueError as e:
|
76
|
-
logger.warning("Thread count {}: {}".format(thread_count, e))
|
77
|
-
return False
|
78
|
-
except TypeError:
|
79
|
-
logger.debug("Thread count not configured. The default value will be used.")
|
80
|
-
return False
|
81
|
-
|
82
|
-
|
83
|
-
def validate_not_folder_paths(paths: Union[Optional[List[str]], Optional[str]]) -> bool:
|
84
|
-
if paths is not None:
|
85
|
-
if isinstance(paths, List):
|
86
|
-
for path in paths:
|
87
|
-
__validate_not_folder_path(path)
|
88
|
-
else:
|
89
|
-
__validate_not_folder_path(paths)
|
90
|
-
return True
|
91
|
-
|
92
|
-
|
93
|
-
def __validate_not_folder_path(path: str) -> bool:
|
94
|
-
if os.path.isdir(path):
|
95
|
-
raise FrogMLValidationError(
|
96
|
-
"file '{}' must be a file, but is a directory.".format(path)
|
97
|
-
)
|
98
|
-
return True
|
99
|
-
|
100
|
-
|
101
|
-
def validate_path_exists(path: str) -> bool:
|
102
|
-
if not os.path.exists(path):
|
103
|
-
raise ValueError(f"Provided path does not exists : '{path}'")
|
104
|
-
return True
|