truefoundry 0.3.3__py3-none-any.whl → 0.4.0.dev1__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.
Potentially problematic release.
This version of truefoundry might be problematic. Click here for more details.
- truefoundry/cli/__main__.py +3 -17
- truefoundry/common/__init__.py +0 -0
- truefoundry/common/request_utils.py +56 -0
- truefoundry/deploy/cli/cli.py +1 -1
- truefoundry/deploy/cli/util.py +3 -1
- truefoundry/deploy/lib/auth/credential_provider.py +2 -12
- truefoundry/deploy/lib/clients/servicefoundry_client.py +0 -9
- truefoundry/deploy/lib/exceptions.py +1 -6
- truefoundry/deploy/lib/session.py +1 -16
- truefoundry/langchain/truefoundry_chat.py +1 -1
- truefoundry/langchain/truefoundry_embeddings.py +1 -1
- truefoundry/langchain/truefoundry_llm.py +1 -1
- truefoundry/langchain/utils.py +0 -41
- truefoundry/ml/__init__.py +46 -6
- truefoundry/ml/artifact/__init__.py +0 -0
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +1120 -0
- truefoundry/ml/autogen/__init__.py +0 -0
- truefoundry/ml/autogen/client/__init__.py +373 -0
- truefoundry/ml/autogen/client/api/__init__.py +16 -0
- truefoundry/ml/autogen/client/api/auth_api.py +184 -0
- truefoundry/ml/autogen/client/api/deprecated_api.py +605 -0
- truefoundry/ml/autogen/client/api/experiments_api.py +2109 -0
- truefoundry/ml/autogen/client/api/health_api.py +299 -0
- truefoundry/ml/autogen/client/api/metrics_api.py +371 -0
- truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +7213 -0
- truefoundry/ml/autogen/client/api/python_deployment_config_api.py +201 -0
- truefoundry/ml/autogen/client/api/run_artifacts_api.py +231 -0
- truefoundry/ml/autogen/client/api/runs_api.py +2919 -0
- truefoundry/ml/autogen/client/api_client.py +822 -0
- truefoundry/ml/autogen/client/api_response.py +30 -0
- truefoundry/ml/autogen/client/configuration.py +489 -0
- truefoundry/ml/autogen/client/exceptions.py +161 -0
- truefoundry/ml/autogen/client/models/__init__.py +344 -0
- truefoundry/ml/autogen/client/models/add_custom_metrics_to_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/add_features_to_model_version_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/agent.py +125 -0
- truefoundry/ml/autogen/client/models/agent_app.py +118 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool.py +143 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool_with_fqn.py +144 -0
- truefoundry/ml/autogen/client/models/agent_with_fqn.py +127 -0
- truefoundry/ml/autogen/client/models/artifact_dto.py +115 -0
- truefoundry/ml/autogen/client/models/artifact_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/artifact_type.py +39 -0
- truefoundry/ml/autogen/client/models/artifact_version_dto.py +141 -0
- truefoundry/ml/autogen/client/models/artifact_version_response_dto.py +77 -0
- truefoundry/ml/autogen/client/models/artifact_version_status.py +35 -0
- truefoundry/ml/autogen/client/models/assistant_message.py +89 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/backfill_default_storage_integration_id_request_dto.py +67 -0
- truefoundry/ml/autogen/client/models/blob_storage_reference.py +93 -0
- truefoundry/ml/autogen/client/models/body_get_search_runs_get.py +72 -0
- truefoundry/ml/autogen/client/models/chat_prompt.py +156 -0
- truefoundry/ml/autogen/client/models/chat_prompt_messages_inner.py +171 -0
- truefoundry/ml/autogen/client/models/columns_dto.py +73 -0
- truefoundry/ml/autogen/client/models/content.py +153 -0
- truefoundry/ml/autogen/client/models/content1.py +153 -0
- truefoundry/ml/autogen/client/models/content2.py +174 -0
- truefoundry/ml/autogen/client/models/content2_any_of_inner.py +150 -0
- truefoundry/ml/autogen/client/models/create_artifact_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +66 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +66 -0
- truefoundry/ml/autogen/client/models/create_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/create_experiment_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/create_experiment_response_dto.py +67 -0
- truefoundry/ml/autogen/client/models/create_model_version_request_dto.py +95 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +72 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +68 -0
- truefoundry/ml/autogen/client/models/create_run_request_dto.py +97 -0
- truefoundry/ml/autogen/client/models/create_run_response_dto.py +76 -0
- truefoundry/ml/autogen/client/models/dataset_dto.py +112 -0
- truefoundry/ml/autogen/client/models/dataset_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/delete_artifact_versions_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/delete_model_version_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_run_request.py +65 -0
- truefoundry/ml/autogen/client/models/delete_tag_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/experiment_dto.py +127 -0
- truefoundry/ml/autogen/client/models/experiment_id_request_dto.py +67 -0
- truefoundry/ml/autogen/client/models/experiment_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/experiment_tag_dto.py +69 -0
- truefoundry/ml/autogen/client/models/feature_dto.py +68 -0
- truefoundry/ml/autogen/client/models/feature_value_type.py +35 -0
- truefoundry/ml/autogen/client/models/file_info_dto.py +76 -0
- truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +101 -0
- truefoundry/ml/autogen/client/models/get_experiment_response_dto.py +88 -0
- truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +76 -0
- truefoundry/ml/autogen/client/models/get_metric_history_response.py +79 -0
- truefoundry/ml/autogen/client/models/get_signed_url_for_dataset_write_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_response_dto.py +83 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_write_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +74 -0
- truefoundry/ml/autogen/client/models/http_validation_error.py +82 -0
- truefoundry/ml/autogen/client/models/image_content_part.py +87 -0
- truefoundry/ml/autogen/client/models/image_url.py +75 -0
- truefoundry/ml/autogen/client/models/internal_metadata.py +180 -0
- truefoundry/ml/autogen/client/models/latest_run_log_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_request_dto.py +107 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_artifacts_request_dto.py +96 -0
- truefoundry/ml/autogen/client/models/list_artifacts_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_colums_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/list_datasets_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_datasets_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_experiments_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_version_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_versions_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_latest_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_metric_history_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/list_metric_history_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_model_version_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_model_versions_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/list_models_request_dto.py +89 -0
- truefoundry/ml/autogen/client/models/list_models_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_artifacts_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_seed_experiments_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/log_batch_request_dto.py +106 -0
- truefoundry/ml/autogen/client/models/log_metric_request_dto.py +80 -0
- truefoundry/ml/autogen/client/models/log_param_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/method.py +37 -0
- truefoundry/ml/autogen/client/models/metric_collection_dto.py +82 -0
- truefoundry/ml/autogen/client/models/metric_dto.py +76 -0
- truefoundry/ml/autogen/client/models/mime_type.py +37 -0
- truefoundry/ml/autogen/client/models/model_configuration.py +103 -0
- truefoundry/ml/autogen/client/models/model_dto.py +122 -0
- truefoundry/ml/autogen/client/models/model_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/model_schema_dto.py +85 -0
- truefoundry/ml/autogen/client/models/model_version_dto.py +163 -0
- truefoundry/ml/autogen/client/models/model_version_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_dto.py +107 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_storage_provider.py +34 -0
- truefoundry/ml/autogen/client/models/notify_artifact_version_failure_dto.py +65 -0
- truefoundry/ml/autogen/client/models/openapi_spec.py +152 -0
- truefoundry/ml/autogen/client/models/param_dto.py +66 -0
- truefoundry/ml/autogen/client/models/parameters.py +84 -0
- truefoundry/ml/autogen/client/models/prediction_type.py +34 -0
- truefoundry/ml/autogen/client/models/resolve_agent_app_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/restore_run_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/run_data_dto.py +104 -0
- truefoundry/ml/autogen/client/models/run_dto.py +84 -0
- truefoundry/ml/autogen/client/models/run_info_dto.py +105 -0
- truefoundry/ml/autogen/client/models/run_log_dto.py +90 -0
- truefoundry/ml/autogen/client/models/run_log_input_dto.py +80 -0
- truefoundry/ml/autogen/client/models/run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/run_tag_dto.py +66 -0
- truefoundry/ml/autogen/client/models/search_runs_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/search_runs_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/set_tag_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/signed_url_dto.py +69 -0
- truefoundry/ml/autogen/client/models/stop.py +152 -0
- truefoundry/ml/autogen/client/models/store_run_logs_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/system_message.py +89 -0
- truefoundry/ml/autogen/client/models/text.py +153 -0
- truefoundry/ml/autogen/client/models/text_content_part.py +84 -0
- truefoundry/ml/autogen/client/models/update_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_experiment_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/update_run_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/update_run_response_dto.py +76 -0
- truefoundry/ml/autogen/client/models/url.py +153 -0
- truefoundry/ml/autogen/client/models/user_message.py +89 -0
- truefoundry/ml/autogen/client/models/validation_error.py +87 -0
- truefoundry/ml/autogen/client/models/validation_error_loc_inner.py +154 -0
- truefoundry/ml/autogen/client/rest.py +426 -0
- truefoundry/ml/autogen/client_README.md +322 -0
- truefoundry/ml/cli/__init__.py +0 -0
- truefoundry/ml/cli/cli.py +18 -0
- truefoundry/ml/cli/commands/__init__.py +3 -0
- truefoundry/ml/cli/commands/download.py +87 -0
- truefoundry/ml/constants.py +84 -0
- truefoundry/ml/enums.py +70 -0
- truefoundry/ml/env_vars.py +13 -0
- truefoundry/ml/exceptions.py +8 -0
- truefoundry/ml/git_info.py +60 -0
- truefoundry/ml/internal_namespace.py +52 -0
- truefoundry/ml/log_types/__init__.py +4 -0
- truefoundry/ml/log_types/artifacts/artifact.py +427 -0
- truefoundry/ml/log_types/artifacts/constants.py +33 -0
- truefoundry/ml/log_types/artifacts/dataset.py +383 -0
- truefoundry/ml/log_types/artifacts/general_artifact.py +110 -0
- truefoundry/ml/log_types/artifacts/model.py +628 -0
- truefoundry/ml/log_types/artifacts/model_extras.py +48 -0
- truefoundry/ml/log_types/artifacts/utils.py +161 -0
- truefoundry/ml/log_types/image/__init__.py +3 -0
- truefoundry/ml/log_types/image/constants.py +8 -0
- truefoundry/ml/log_types/image/image.py +358 -0
- truefoundry/ml/log_types/image/image_normalizer.py +101 -0
- truefoundry/ml/log_types/image/types.py +68 -0
- truefoundry/ml/log_types/plot.py +281 -0
- truefoundry/ml/log_types/pydantic_base.py +10 -0
- truefoundry/ml/log_types/utils.py +12 -0
- truefoundry/ml/logger.py +17 -0
- truefoundry/ml/login.py +241 -0
- truefoundry/ml/mlfoundry_api.py +1620 -0
- truefoundry/ml/mlfoundry_run.py +1238 -0
- truefoundry/ml/run_utils.py +102 -0
- truefoundry/ml/services/__init__.py +0 -0
- truefoundry/ml/services/auth_service.py +109 -0
- truefoundry/ml/services/entities.py +108 -0
- truefoundry/ml/services/servicefoundry_service.py +35 -0
- truefoundry/ml/services/utils.py +122 -0
- truefoundry/ml/session.py +271 -0
- truefoundry/ml/validation_utils.py +346 -0
- truefoundry/pydantic_v1.py +5 -1
- {truefoundry-0.3.3.dist-info → truefoundry-0.4.0.dev1.dist-info}/METADATA +18 -11
- truefoundry-0.4.0.dev1.dist-info/RECORD +342 -0
- truefoundry-0.3.3.dist-info/RECORD +0 -136
- /truefoundry/{python_deploy_codegen.py → deploy/python_deploy_codegen.py} +0 -0
- {truefoundry-0.3.3.dist-info → truefoundry-0.4.0.dev1.dist-info}/WHEEL +0 -0
- {truefoundry-0.3.3.dist-info → truefoundry-0.4.0.dev1.dist-info}/entry_points.txt +0 -0
truefoundry/cli/__main__.py
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
|
|
3
|
-
import click
|
|
3
|
+
import rich_click as click
|
|
4
4
|
|
|
5
5
|
from truefoundry.deploy.cli.cli import create_truefoundry_cli
|
|
6
|
-
|
|
7
|
-
MLFOUNDRY_INSTALLED = True
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
try:
|
|
11
|
-
from mlfoundry.cli.commands import download
|
|
12
|
-
except ImportError:
|
|
13
|
-
MLFOUNDRY_INSTALLED = False
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@click.group()
|
|
17
|
-
def ml():
|
|
18
|
-
"""MlFoundry CLI"""
|
|
6
|
+
from truefoundry.ml.cli.cli import get_ml_cli
|
|
19
7
|
|
|
20
8
|
|
|
21
9
|
def main():
|
|
@@ -25,9 +13,7 @@ def main():
|
|
|
25
13
|
# If it is another kind of object, it will be printed and the system exit status will be one (i.e., failure).
|
|
26
14
|
try:
|
|
27
15
|
cli = create_truefoundry_cli()
|
|
28
|
-
|
|
29
|
-
ml.add_command(download)
|
|
30
|
-
cli.add_command(ml)
|
|
16
|
+
cli.add_command(get_ml_cli())
|
|
31
17
|
except Exception as e:
|
|
32
18
|
raise click.exceptions.UsageError(message=str(e)) from e
|
|
33
19
|
sys.exit(cli())
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from requests.adapters import HTTPAdapter
|
|
3
|
+
from urllib3 import Retry
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def urllib3_retry(
|
|
7
|
+
retries=5,
|
|
8
|
+
backoff_factor=0.3,
|
|
9
|
+
status_forcelist=(408, 429, 500, 502, 503, 504),
|
|
10
|
+
method_whitelist=frozenset({"GET", "POST"}),
|
|
11
|
+
):
|
|
12
|
+
retry = Retry(
|
|
13
|
+
total=retries,
|
|
14
|
+
read=retries,
|
|
15
|
+
connect=retries,
|
|
16
|
+
status=retries,
|
|
17
|
+
backoff_factor=backoff_factor,
|
|
18
|
+
allowed_methods=method_whitelist,
|
|
19
|
+
status_forcelist=status_forcelist,
|
|
20
|
+
respect_retry_after_header=True,
|
|
21
|
+
)
|
|
22
|
+
return retry
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def requests_retry_session(
|
|
26
|
+
retries=5,
|
|
27
|
+
backoff_factor=0.3,
|
|
28
|
+
status_forcelist=(408, 429, 500, 502, 503, 504),
|
|
29
|
+
method_whitelist=frozenset({"GET", "POST"}),
|
|
30
|
+
session=None,
|
|
31
|
+
):
|
|
32
|
+
"""
|
|
33
|
+
Returns a `requests` session with retry capabilities for certain HTTP status codes.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
retries (int): The number of retries for HTTP requests.
|
|
37
|
+
backoff_factor (float): The backoff factor for exponential backoff during retries.
|
|
38
|
+
status_forcelist (tuple): A tuple of HTTP status codes that should trigger a retry.
|
|
39
|
+
method_whitelist (frozenset): The set of HTTP methods that should be retried.
|
|
40
|
+
session (requests.Session, optional): An optional existing requests session to use.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
requests.Session: A session with retry capabilities.
|
|
44
|
+
"""
|
|
45
|
+
# Implementation taken from https://www.peterbe.com/plog/best-practice-with-retries-with-requests
|
|
46
|
+
session = session or requests.Session()
|
|
47
|
+
retry = urllib3_retry(
|
|
48
|
+
retries=retries,
|
|
49
|
+
backoff_factor=backoff_factor,
|
|
50
|
+
status_forcelist=status_forcelist,
|
|
51
|
+
method_whitelist=method_whitelist,
|
|
52
|
+
)
|
|
53
|
+
adapter = HTTPAdapter(max_retries=retry)
|
|
54
|
+
session.mount("http://", adapter)
|
|
55
|
+
session.mount("https://", adapter)
|
|
56
|
+
return session
|
truefoundry/deploy/cli/cli.py
CHANGED
|
@@ -24,7 +24,7 @@ from truefoundry.version import __version__
|
|
|
24
24
|
click.rich_click.USE_RICH_MARKUP = True
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
def create_truefoundry_cli():
|
|
27
|
+
def create_truefoundry_cli() -> click.MultiCommand:
|
|
28
28
|
"""Generates CLI by combining all subcommands into a main CLI and returns in
|
|
29
29
|
|
|
30
30
|
Returns:
|
truefoundry/deploy/cli/util.py
CHANGED
|
@@ -36,7 +36,9 @@ def handle_exception(exception):
|
|
|
36
36
|
)
|
|
37
37
|
elif isinstance(exception, ConnectionError):
|
|
38
38
|
print_dict_as_table_panel(
|
|
39
|
-
{
|
|
39
|
+
{
|
|
40
|
+
"Error": "Couldn't connect to TrueFoundry. Please make sure that the provided `--host` is correct."
|
|
41
|
+
},
|
|
40
42
|
title="Command Failed",
|
|
41
43
|
border_style="red",
|
|
42
44
|
)
|
|
@@ -31,10 +31,6 @@ class CredentialProvider(ABC):
|
|
|
31
31
|
|
|
32
32
|
class EnvCredentialProvider(CredentialProvider):
|
|
33
33
|
def __init__(self) -> None:
|
|
34
|
-
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
35
|
-
ServiceFoundryServiceClient,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
34
|
logger.debug("Using env var credential provider")
|
|
39
35
|
api_key = os.getenv(API_KEY_ENV_NAME)
|
|
40
36
|
if not api_key:
|
|
@@ -45,13 +41,7 @@ class EnvCredentialProvider(CredentialProvider):
|
|
|
45
41
|
base_url = resolve_base_url().strip("/")
|
|
46
42
|
self._host = base_url
|
|
47
43
|
self._auth_service = AuthServiceClient.from_base_url(base_url=base_url)
|
|
48
|
-
|
|
49
|
-
servicefoundry_client = ServiceFoundryServiceClient(
|
|
50
|
-
init_session=False, base_url=base_url
|
|
51
|
-
)
|
|
52
|
-
self._token: Token = servicefoundry_client.get_token_from_api_key(
|
|
53
|
-
api_key=api_key
|
|
54
|
-
)
|
|
44
|
+
self._token: Token = Token(access_token=api_key, refresh_token=None)
|
|
55
45
|
|
|
56
46
|
@staticmethod
|
|
57
47
|
def can_provide() -> bool:
|
|
@@ -123,7 +113,7 @@ class FileCredentialProvider(CredentialProvider):
|
|
|
123
113
|
return self.token
|
|
124
114
|
|
|
125
115
|
raise Exception(
|
|
126
|
-
"Credentials on disk changed while
|
|
116
|
+
"Credentials on disk changed while truefoundry was running."
|
|
127
117
|
)
|
|
128
118
|
|
|
129
119
|
@property
|
|
@@ -28,7 +28,6 @@ from truefoundry.deploy.lib.model.entity import (
|
|
|
28
28
|
JobRun,
|
|
29
29
|
PythonSDKConfig,
|
|
30
30
|
TenantInfo,
|
|
31
|
-
Token,
|
|
32
31
|
TriggerJobResult,
|
|
33
32
|
Workspace,
|
|
34
33
|
WorkspaceResources,
|
|
@@ -712,14 +711,6 @@ class ServiceFoundryServiceClient:
|
|
|
712
711
|
response = request_handling(res)
|
|
713
712
|
return parse_obj_as(List[Deployment], response)
|
|
714
713
|
|
|
715
|
-
@check_min_cli_version
|
|
716
|
-
def get_token_from_api_key(self, api_key: str) -> Token:
|
|
717
|
-
url = f"{self._api_server_url}/{VERSION_PREFIX}/oauth/api-key/token"
|
|
718
|
-
data = {"apiKey": api_key}
|
|
719
|
-
res = requests.get(url, params=data)
|
|
720
|
-
res = request_handling(res)
|
|
721
|
-
return Token.parse_obj(res)
|
|
722
|
-
|
|
723
714
|
@check_min_cli_version
|
|
724
715
|
def apply(self, manifest: Dict[str, Any]) -> None:
|
|
725
716
|
url = f"{self._api_server_url}/{VERSION_PREFIX}/apply"
|
|
@@ -6,13 +6,11 @@ class BadRequestException(Exception):
|
|
|
6
6
|
super().__init__()
|
|
7
7
|
self.status_code = status_code
|
|
8
8
|
self.message = message
|
|
9
|
+
self.status_code = status_code
|
|
9
10
|
|
|
10
11
|
def __str__(self):
|
|
11
12
|
return self.message
|
|
12
13
|
|
|
13
|
-
def __repr__(self):
|
|
14
|
-
return self.message
|
|
15
|
-
|
|
16
14
|
|
|
17
15
|
class ConfigurationException(Exception):
|
|
18
16
|
def __init__(self, message: Optional[str] = None):
|
|
@@ -21,6 +19,3 @@ class ConfigurationException(Exception):
|
|
|
21
19
|
|
|
22
20
|
def __str__(self):
|
|
23
21
|
return self.message
|
|
24
|
-
|
|
25
|
-
def __repr__(self):
|
|
26
|
-
return self.message
|
|
@@ -7,9 +7,6 @@ from truefoundry.deploy.io.output_callback import OutputCallBack
|
|
|
7
7
|
from truefoundry.deploy.lib.auth.auth_service_client import AuthServiceClient
|
|
8
8
|
from truefoundry.deploy.lib.auth.credential_file_manager import CredentialsFileManager
|
|
9
9
|
from truefoundry.deploy.lib.auth.credential_provider import EnvCredentialProvider
|
|
10
|
-
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
11
|
-
ServiceFoundryServiceClient,
|
|
12
|
-
)
|
|
13
10
|
from truefoundry.deploy.lib.clients.utils import resolve_base_url
|
|
14
11
|
from truefoundry.deploy.lib.const import (
|
|
15
12
|
API_KEY_ENV_NAME,
|
|
@@ -85,12 +82,7 @@ def login(
|
|
|
85
82
|
return False
|
|
86
83
|
|
|
87
84
|
if api_key:
|
|
88
|
-
|
|
89
|
-
init_session=False, base_url=host
|
|
90
|
-
)
|
|
91
|
-
token = _login_with_api_key(
|
|
92
|
-
api_key=api_key, servicefoundry_client=servicefoundry_client
|
|
93
|
-
)
|
|
85
|
+
token = Token(access_token=api_key, refresh_token=None)
|
|
94
86
|
else:
|
|
95
87
|
auth_service = AuthServiceClient.from_base_url(base_url=host)
|
|
96
88
|
# interactive login
|
|
@@ -122,13 +114,6 @@ def logout(
|
|
|
122
114
|
output_hook.print_line(PROMPT_ALREADY_LOGGED_OUT)
|
|
123
115
|
|
|
124
116
|
|
|
125
|
-
def _login_with_api_key(
|
|
126
|
-
api_key: str, servicefoundry_client: ServiceFoundryServiceClient
|
|
127
|
-
) -> Token:
|
|
128
|
-
logger.debug("Logging in with api key")
|
|
129
|
-
return servicefoundry_client.get_token_from_api_key(api_key=api_key)
|
|
130
|
-
|
|
131
|
-
|
|
132
117
|
def _login_with_device_code(
|
|
133
118
|
base_url: str,
|
|
134
119
|
auth_service: AuthServiceClient,
|
|
@@ -10,8 +10,8 @@ from langchain.schema.messages import (
|
|
|
10
10
|
SystemMessage,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
+
from truefoundry.common.request_utils import requests_retry_session
|
|
13
14
|
from truefoundry.langchain.utils import (
|
|
14
|
-
requests_retry_session,
|
|
15
15
|
validate_tfy_environment,
|
|
16
16
|
)
|
|
17
17
|
from truefoundry.logger import logger
|
|
@@ -6,8 +6,8 @@ import tqdm
|
|
|
6
6
|
from langchain.embeddings.base import Embeddings
|
|
7
7
|
from langchain.pydantic_v1 import BaseModel, Extra, Field, root_validator
|
|
8
8
|
|
|
9
|
+
from truefoundry.common.request_utils import requests_retry_session
|
|
9
10
|
from truefoundry.langchain.utils import (
|
|
10
|
-
requests_retry_session,
|
|
11
11
|
validate_tfy_environment,
|
|
12
12
|
)
|
|
13
13
|
from truefoundry.logger import logger
|
|
@@ -3,8 +3,8 @@ from typing import Any, Dict, List, Optional
|
|
|
3
3
|
from langchain.llms.base import LLM
|
|
4
4
|
from langchain.pydantic_v1 import Extra, Field, root_validator
|
|
5
5
|
|
|
6
|
+
from truefoundry.common.request_utils import requests_retry_session
|
|
6
7
|
from truefoundry.langchain.utils import (
|
|
7
|
-
requests_retry_session,
|
|
8
8
|
validate_tfy_environment,
|
|
9
9
|
)
|
|
10
10
|
from truefoundry.logger import logger
|
truefoundry/langchain/utils.py
CHANGED
|
@@ -2,10 +2,7 @@ import os
|
|
|
2
2
|
from typing import Dict, List, Optional
|
|
3
3
|
from urllib.parse import urljoin
|
|
4
4
|
|
|
5
|
-
import requests
|
|
6
5
|
from langchain.pydantic_v1 import BaseModel
|
|
7
|
-
from requests.adapters import HTTPAdapter
|
|
8
|
-
from urllib3.util.retry import Retry
|
|
9
6
|
|
|
10
7
|
from truefoundry.deploy.lib.auth.servicefoundry_session import ServiceFoundrySession
|
|
11
8
|
|
|
@@ -45,41 +42,3 @@ def validate_tfy_environment(values: Dict):
|
|
|
45
42
|
values["tfy_llm_gateway_url"] = gateway_url
|
|
46
43
|
values["tfy_api_key"] = api_key
|
|
47
44
|
return values
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def requests_retry_session(
|
|
51
|
-
retries=5,
|
|
52
|
-
backoff_factor=0.3,
|
|
53
|
-
status_forcelist=(500, 502, 503, 504),
|
|
54
|
-
method_whitelist=frozenset({"GET", "POST"}),
|
|
55
|
-
session=None,
|
|
56
|
-
):
|
|
57
|
-
"""
|
|
58
|
-
Returns a `requests` session with retry capabilities for certain HTTP status codes.
|
|
59
|
-
|
|
60
|
-
Args:
|
|
61
|
-
retries (int): The number of retries for HTTP requests.
|
|
62
|
-
backoff_factor (float): The backoff factor for exponential backoff during retries.
|
|
63
|
-
status_forcelist (tuple): A tuple of HTTP status codes that should trigger a retry.
|
|
64
|
-
method_whitelist (frozenset): The set of HTTP methods that should be retried.
|
|
65
|
-
session (requests.Session, optional): An optional existing requests session to use.
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
requests.Session: A session with retry capabilities.
|
|
69
|
-
"""
|
|
70
|
-
# Implementation taken from https://www.peterbe.com/plog/best-practice-with-retries-with-requests
|
|
71
|
-
session = session or requests.Session()
|
|
72
|
-
retry = Retry(
|
|
73
|
-
total=retries,
|
|
74
|
-
read=retries,
|
|
75
|
-
connect=retries,
|
|
76
|
-
status=retries,
|
|
77
|
-
backoff_factor=backoff_factor,
|
|
78
|
-
allowed_methods=method_whitelist,
|
|
79
|
-
status_forcelist=status_forcelist,
|
|
80
|
-
respect_retry_after_header=True,
|
|
81
|
-
)
|
|
82
|
-
adapter = HTTPAdapter(max_retries=retry)
|
|
83
|
-
session.mount("http://", adapter)
|
|
84
|
-
session.mount("https://", adapter)
|
|
85
|
-
return session
|
truefoundry/ml/__init__.py
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
2
|
+
FeatureDto as Feature,
|
|
3
|
+
)
|
|
4
|
+
from truefoundry.ml.enums import (
|
|
5
|
+
DataSlice,
|
|
6
|
+
FileFormat,
|
|
7
|
+
ModelFramework,
|
|
8
|
+
ModelType,
|
|
9
|
+
ViewType,
|
|
10
|
+
)
|
|
11
|
+
from truefoundry.ml.exceptions import MlFoundryException
|
|
12
|
+
from truefoundry.ml.log_types import Image, Plot
|
|
13
|
+
from truefoundry.ml.log_types.artifacts.artifact import ArtifactPath, ArtifactVersion
|
|
14
|
+
from truefoundry.ml.log_types.artifacts.dataset import DataDirectory, DataDirectoryPath
|
|
15
|
+
from truefoundry.ml.log_types.artifacts.model import (
|
|
16
|
+
ModelVersion,
|
|
17
|
+
)
|
|
18
|
+
from truefoundry.ml.log_types.artifacts.model_extras import CustomMetric, ModelSchema
|
|
19
|
+
from truefoundry.ml.logger import init_logger
|
|
20
|
+
from truefoundry.ml.login import login
|
|
21
|
+
from truefoundry.ml.mlfoundry_api import get_client
|
|
22
|
+
from truefoundry.ml.mlfoundry_run import MlFoundryRun
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"ArtifactPath",
|
|
26
|
+
"ArtifactVersion",
|
|
27
|
+
"CustomMetric",
|
|
28
|
+
"DataDirectory",
|
|
29
|
+
"DataDirectoryPath",
|
|
30
|
+
"DataSlice",
|
|
31
|
+
"Feature",
|
|
32
|
+
"FileFormat",
|
|
33
|
+
"Image",
|
|
34
|
+
"MlFoundryRun",
|
|
35
|
+
"MlFoundryException",
|
|
36
|
+
"ModelFramework",
|
|
37
|
+
"ModelSchema",
|
|
38
|
+
"ModelType",
|
|
39
|
+
"ModelVersion",
|
|
40
|
+
"Plot",
|
|
41
|
+
"ViewType",
|
|
42
|
+
"get_client",
|
|
43
|
+
"login",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
init_logger()
|
|
File without changes
|