truefoundry 0.3.4__py3-none-any.whl → 0.4.0__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/__init__.py +2 -0
- truefoundry/autodeploy/agents/developer.py +1 -1
- truefoundry/autodeploy/agents/project_identifier.py +2 -2
- truefoundry/autodeploy/agents/tester.py +1 -1
- truefoundry/autodeploy/cli.py +1 -1
- truefoundry/autodeploy/tools/list_files.py +1 -1
- truefoundry/cli/__main__.py +3 -17
- truefoundry/common/__init__.py +0 -0
- truefoundry/{deploy/lib/auth → common}/auth_service_client.py +50 -40
- truefoundry/common/constants.py +12 -0
- truefoundry/{deploy/lib/auth → common}/credential_file_manager.py +7 -7
- truefoundry/{deploy/lib/auth → common}/credential_provider.py +10 -23
- truefoundry/common/entities.py +124 -0
- truefoundry/common/exceptions.py +12 -0
- truefoundry/common/request_utils.py +84 -0
- truefoundry/common/servicefoundry_client.py +91 -0
- truefoundry/common/utils.py +56 -0
- truefoundry/deploy/auto_gen/models.py +4 -6
- truefoundry/deploy/cli/cli.py +3 -1
- truefoundry/deploy/cli/commands/apply_command.py +1 -1
- truefoundry/deploy/cli/commands/build_command.py +1 -1
- truefoundry/deploy/cli/commands/deploy_command.py +1 -1
- truefoundry/deploy/cli/commands/login_command.py +2 -2
- truefoundry/deploy/cli/commands/patch_application_command.py +1 -1
- truefoundry/deploy/cli/commands/patch_command.py +1 -1
- truefoundry/deploy/cli/commands/terminate_comand.py +1 -1
- truefoundry/deploy/cli/util.py +1 -1
- truefoundry/deploy/function_service/remote/remote.py +1 -1
- truefoundry/deploy/lib/auth/servicefoundry_session.py +2 -2
- truefoundry/deploy/lib/clients/servicefoundry_client.py +120 -159
- truefoundry/deploy/lib/const.py +1 -35
- truefoundry/deploy/lib/exceptions.py +0 -16
- truefoundry/deploy/lib/model/entity.py +1 -112
- truefoundry/deploy/lib/session.py +14 -42
- truefoundry/deploy/lib/util.py +0 -37
- truefoundry/{python_deploy_codegen.py → deploy/python_deploy_codegen.py} +2 -2
- truefoundry/deploy/v2/lib/deploy.py +3 -3
- truefoundry/deploy/v2/lib/deployable_patched_models.py +1 -1
- 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 +37 -6
- truefoundry/ml/artifact/__init__.py +0 -0
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +1161 -0
- truefoundry/ml/autogen/__init__.py +0 -0
- truefoundry/ml/autogen/client/__init__.py +370 -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 +1944 -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 +341 -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/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 +65 -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 +65 -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 +67 -0
- truefoundry/ml/autogen/client/models/create_run_request_dto.py +97 -0
- truefoundry/ml/autogen/client/models/create_run_response_dto.py +75 -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 +75 -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 +73 -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 +170 -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 +75 -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 +320 -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/clients/__init__.py +0 -0
- truefoundry/ml/clients/entities.py +8 -0
- truefoundry/ml/clients/servicefoundry_client.py +45 -0
- truefoundry/ml/clients/utils.py +122 -0
- truefoundry/ml/constants.py +84 -0
- truefoundry/ml/entities.py +62 -0
- truefoundry/ml/enums.py +70 -0
- truefoundry/ml/env_vars.py +9 -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 +431 -0
- truefoundry/ml/log_types/artifacts/constants.py +33 -0
- truefoundry/ml/log_types/artifacts/dataset.py +384 -0
- truefoundry/ml/log_types/artifacts/general_artifact.py +110 -0
- truefoundry/ml/log_types/artifacts/model.py +611 -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 +357 -0
- truefoundry/ml/log_types/image/image_normalizer.py +102 -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/mlfoundry_api.py +1575 -0
- truefoundry/ml/mlfoundry_run.py +1203 -0
- truefoundry/ml/run_utils.py +93 -0
- truefoundry/ml/session.py +168 -0
- truefoundry/ml/validation_utils.py +346 -0
- truefoundry/pydantic_v1.py +6 -2
- truefoundry/workflow/__init__.py +16 -1
- {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/METADATA +21 -14
- truefoundry-0.4.0.dist-info/RECORD +344 -0
- truefoundry/deploy/lib/clients/utils.py +0 -41
- truefoundry-0.3.4.dist-info/RECORD +0 -136
- {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/WHEEL +0 -0
- {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import os
|
|
3
|
+
import posixpath
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from truefoundry.ml.internal_namespace import NAMESPACE
|
|
7
|
+
|
|
8
|
+
DEFAULT_TRACKING_URI = "https://app.truefoundry.com"
|
|
9
|
+
RUN_LOGS_DIR = posixpath.join("mlf", "run-logs")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# TODO (chiragjn): This should be run specific, otherwise this will only be initialised once per
|
|
13
|
+
# interpreter
|
|
14
|
+
MLFOUNDRY_TMP_FOLDER = Path(os.path.abspath("./.mlfoundry"))
|
|
15
|
+
RUN_TMP_FOLDER = Path(
|
|
16
|
+
os.path.join(MLFOUNDRY_TMP_FOLDER, "logdirs")
|
|
17
|
+
) # this is the log directory
|
|
18
|
+
|
|
19
|
+
RUN_PREDICTIONS_FOLDER = Path(
|
|
20
|
+
os.path.join(RUN_TMP_FOLDER, "predictions")
|
|
21
|
+
) # path to store predictions
|
|
22
|
+
RUN_DATASET_FOLDER = Path(
|
|
23
|
+
os.path.join(RUN_TMP_FOLDER, "datasets")
|
|
24
|
+
) # path to store datasets
|
|
25
|
+
# path to store dataset stats
|
|
26
|
+
RUN_STATS_FOLDER = Path(os.path.join(RUN_TMP_FOLDER, "stats"))
|
|
27
|
+
RUN_METRICS_FOLDER = Path(os.path.join(RUN_TMP_FOLDER, "metrics"))
|
|
28
|
+
|
|
29
|
+
GET_RUN_TMP_FOLDER = Path(
|
|
30
|
+
os.path.join(MLFOUNDRY_TMP_FOLDER, "getdirs")
|
|
31
|
+
) # this is the log directory
|
|
32
|
+
GET_RUN_PREDICTIONS_FOLDER = Path(
|
|
33
|
+
os.path.join(GET_RUN_TMP_FOLDER, "predictions")
|
|
34
|
+
) # path to store predictions
|
|
35
|
+
GET_RUN_DATASET_FOLDER = Path(
|
|
36
|
+
os.path.join(GET_RUN_TMP_FOLDER, "datasets")
|
|
37
|
+
) # path to store datasets
|
|
38
|
+
|
|
39
|
+
TIME_LIMIT_THRESHOLD = datetime.timedelta(minutes=1)
|
|
40
|
+
FILE_SIZE_LIMIT_THRESHOLD = pow(10, 7) # 10MB
|
|
41
|
+
|
|
42
|
+
MULTI_DIMENSIONAL_METRICS = "multi_dimensional_metrics" # multi dimensional metrics
|
|
43
|
+
NON_MULTI_DIMENSIONAL_METRICS = (
|
|
44
|
+
"non_multi_dimensional_metrics" # non-multi dimensional metrics
|
|
45
|
+
)
|
|
46
|
+
PROB_MULTI_DIMENSIONAL_METRICS = (
|
|
47
|
+
"prob_multi_dimensional_metrics" # multi dimensional metrics
|
|
48
|
+
)
|
|
49
|
+
PROB_NON_MULTI_DIMENSIONAL_METRICS = (
|
|
50
|
+
"prob_non_multi_dimensional_metrics" # non-multi dimensional metrics
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
LATEST_ARTIFACT_OR_MODEL_VERSION = "latest"
|
|
54
|
+
|
|
55
|
+
ACTUAL_PREDICTION_COUNTS = "actuals_predictions_counts"
|
|
56
|
+
MLF_FOLDER_NAME = "mlf"
|
|
57
|
+
MLRUNS_FOLDER = "mlruns"
|
|
58
|
+
MLRUNS_FOLDER_NAME = Path(os.path.join(MLF_FOLDER_NAME, MLRUNS_FOLDER))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Runs Name and DF constants
|
|
62
|
+
RUN_ID_COL_NAME = "run_id"
|
|
63
|
+
RUN_NAME_COL_NAME = "run_name"
|
|
64
|
+
|
|
65
|
+
TIME_FORMAT = "%Y-%m-%d_%H-%M-%S"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
GIT_COMMIT_TAG_NAME = NAMESPACE("git.commit_sha")
|
|
69
|
+
GIT_BRANCH_TAG_NAME = NAMESPACE("git.branch_name")
|
|
70
|
+
GIT_REMOTE_URL_NAME = NAMESPACE("git.remote_url")
|
|
71
|
+
GIT_DIRTY_TAG_NAME = NAMESPACE("git.dirty")
|
|
72
|
+
PATCH_FILE_ARTIFACT_DIR = NAMESPACE / "git"
|
|
73
|
+
LOG_DATASET_ARTIFACT_DIR = NAMESPACE / "datasets"
|
|
74
|
+
# without .txt patch file does not load on UI
|
|
75
|
+
PATCH_FILE_NAME = "uncommitted_changes.patch.txt"
|
|
76
|
+
|
|
77
|
+
PYTHON_VERSION_TAG_NAME = NAMESPACE("python_version")
|
|
78
|
+
MLFOUNDRY_VERSION_TAG_NAME = NAMESPACE("mlfoundry_version")
|
|
79
|
+
TRUEFOUNDRY_VERSION_TAG_NAME = NAMESPACE("truefoundry_version")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
ALM_SCALAR_METRICS_PATTERN = NAMESPACE("auto_logged_metrics.{data_slice}.{metric_name}")
|
|
83
|
+
ALM_ARTIFACT_PATH = NAMESPACE / "auto_logged_metrics"
|
|
84
|
+
ALM_METRICS_FILE_NAME = "metrics.json"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
|
|
3
|
+
from truefoundry.ml.autogen.client import ( # type: ignore[attr-defined]
|
|
4
|
+
FileInfoDto,
|
|
5
|
+
MetricDto,
|
|
6
|
+
)
|
|
7
|
+
from truefoundry.pydantic_v1 import (
|
|
8
|
+
BaseModel,
|
|
9
|
+
Field,
|
|
10
|
+
StrictBool,
|
|
11
|
+
StrictFloat,
|
|
12
|
+
StrictInt,
|
|
13
|
+
StrictStr,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Metric(BaseModel):
|
|
18
|
+
key: StrictStr = Field(...)
|
|
19
|
+
value: Optional[Union[StrictFloat, StrictInt]] = None
|
|
20
|
+
timestamp: Optional[StrictInt] = None
|
|
21
|
+
step: Optional[StrictInt] = 0
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def from_dto(cls, dto: MetricDto) -> "Metric":
|
|
25
|
+
return cls(
|
|
26
|
+
key=dto.key,
|
|
27
|
+
value=dto.value,
|
|
28
|
+
timestamp=dto.timestamp,
|
|
29
|
+
step=dto.step,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def to_dto(self) -> MetricDto:
|
|
33
|
+
return MetricDto(
|
|
34
|
+
key=self.key,
|
|
35
|
+
value=self.value,
|
|
36
|
+
timestamp=self.timestamp,
|
|
37
|
+
step=self.step,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class FileInfo(BaseModel):
|
|
42
|
+
path: StrictStr
|
|
43
|
+
is_dir: StrictBool
|
|
44
|
+
file_size: Optional[StrictInt] = None
|
|
45
|
+
signed_url: Optional[StrictStr] = None
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def from_dto(cls, dto: FileInfoDto) -> "FileInfo":
|
|
49
|
+
return cls(
|
|
50
|
+
path=dto.path,
|
|
51
|
+
is_dir=dto.is_dir,
|
|
52
|
+
file_size=dto.file_size,
|
|
53
|
+
signed_url=dto.signed_url,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def to_dto(self) -> FileInfoDto:
|
|
57
|
+
return FileInfoDto(
|
|
58
|
+
path=self.path,
|
|
59
|
+
is_dir=self.is_dir,
|
|
60
|
+
file_size=self.file_size,
|
|
61
|
+
signed_url=self.signed_url,
|
|
62
|
+
)
|
truefoundry/ml/enums.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
from truefoundry.ml.exceptions import MlFoundryException
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class EnumMissingMixin:
|
|
7
|
+
@classmethod
|
|
8
|
+
def _missing_(cls, value):
|
|
9
|
+
raise MlFoundryException(
|
|
10
|
+
"%r is not a valid %s. Valid types: %s"
|
|
11
|
+
% (
|
|
12
|
+
value,
|
|
13
|
+
cls.__name__,
|
|
14
|
+
", ".join([repr(m.value) for m in cls]), # type: ignore
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ViewType(str, EnumMissingMixin, enum.Enum):
|
|
20
|
+
# TODO (chiragjn): This should come from autogen! And also be exported in __init__.py
|
|
21
|
+
ACTIVE_ONLY = "ACTIVE_ONLY"
|
|
22
|
+
DELETED_ONLY = "DELETED_ONLY"
|
|
23
|
+
HARD_DELETED_ONLY = "HARD_DELETED_ONLY"
|
|
24
|
+
ALL = "ALL"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RunStatus(str, EnumMissingMixin, enum.Enum):
|
|
28
|
+
# TODO (chiragjn): This should come from autogen! And also be exported in __init__.py
|
|
29
|
+
RUNNING = "RUNNING"
|
|
30
|
+
SCHEDULED = "SCHEDULED"
|
|
31
|
+
FINISHED = "FINISHED"
|
|
32
|
+
FAILED = "FAILED"
|
|
33
|
+
KILLED = "KILLED"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FileFormat(EnumMissingMixin, enum.Enum):
|
|
37
|
+
CSV = "csv"
|
|
38
|
+
PARQUET = "parquet"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ModelFramework(EnumMissingMixin, enum.Enum):
|
|
42
|
+
SKLEARN = "sklearn"
|
|
43
|
+
TENSORFLOW = "tensorflow"
|
|
44
|
+
PYTORCH = "pytorch"
|
|
45
|
+
KERAS = "keras"
|
|
46
|
+
XGBOOST = "xgboost"
|
|
47
|
+
LIGHTGBM = "lightgbm"
|
|
48
|
+
FASTAI = "fastai"
|
|
49
|
+
H2O = "h2o"
|
|
50
|
+
ONNX = "onnx"
|
|
51
|
+
SPACY = "spacy"
|
|
52
|
+
STATSMODELS = "statsmodels"
|
|
53
|
+
GLUON = "gluon"
|
|
54
|
+
PADDLE = "paddle"
|
|
55
|
+
TRANSFORMERS = "transformers"
|
|
56
|
+
UNKNOWN = "unknown"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class DataSlice(EnumMissingMixin, enum.Enum):
|
|
60
|
+
TRAIN = "train"
|
|
61
|
+
VALIDATE = "validate"
|
|
62
|
+
TEST = "test"
|
|
63
|
+
PREDICTION = "prediction"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ModelType(EnumMissingMixin, enum.Enum):
|
|
67
|
+
BINARY_CLASSIFICATION = "binary_classification"
|
|
68
|
+
MULTICLASS_CLASSIFICATION = "multiclass_classification"
|
|
69
|
+
REGRESSION = "regression"
|
|
70
|
+
TIMESERIES = "timeseries"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from git import Repo
|
|
4
|
+
from git.exc import InvalidGitRepositoryError
|
|
5
|
+
|
|
6
|
+
from truefoundry.ml.logger import logger
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GitInfo:
|
|
10
|
+
def __init__(self, path: str):
|
|
11
|
+
try:
|
|
12
|
+
self.repo: Repo = self.build_repo(path)
|
|
13
|
+
except InvalidGitRepositoryError as ex:
|
|
14
|
+
# NOTE: gitpython library does not set proper exception message while raising the
|
|
15
|
+
# exception. So we are catching and raising the same exception with proper message
|
|
16
|
+
raise InvalidGitRepositoryError("git repository is not present") from ex
|
|
17
|
+
|
|
18
|
+
def build_repo(self, path: str):
|
|
19
|
+
# https://github.com/gitpython-developers/GitPython/blob/cd29f07b2efda24bdc690626ed557590289d11a6/git/cmd.py#L365
|
|
20
|
+
# looks like the import itself may fail in case the git executable
|
|
21
|
+
# is not found
|
|
22
|
+
# putting the import here so that the caller can handle the exception
|
|
23
|
+
import git
|
|
24
|
+
|
|
25
|
+
repo = git.Repo(path, search_parent_directories=True)
|
|
26
|
+
|
|
27
|
+
return repo
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def current_commit_sha(self) -> str:
|
|
31
|
+
return str(self.repo.head.object.hexsha)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def current_branch_name(self) -> str:
|
|
35
|
+
try:
|
|
36
|
+
branch_name = self.repo.active_branch.name
|
|
37
|
+
return branch_name
|
|
38
|
+
except TypeError as ex:
|
|
39
|
+
# NOTE: TypeError will be raised here if
|
|
40
|
+
# head is in detached state.
|
|
41
|
+
# git checkout commit_sha
|
|
42
|
+
# in this case returning empty string
|
|
43
|
+
logger.warning(f"cannot get branch name because of {ex}")
|
|
44
|
+
return ""
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def remote_url(self) -> Optional[str]:
|
|
48
|
+
remotes = self.repo.remotes
|
|
49
|
+
if len(remotes) != 1:
|
|
50
|
+
logger.warning("either more than one or no remote detected")
|
|
51
|
+
return None
|
|
52
|
+
return remotes[0].url
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def diff_patch(self) -> str:
|
|
56
|
+
return str(self.repo.git.diff("--patch", "HEAD"))
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def is_dirty(self) -> bool:
|
|
60
|
+
return self.repo.is_dirty()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from truefoundry.ml.exceptions import MlFoundryException
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _InternalNamespace:
|
|
8
|
+
NAMESPACE = "mlf"
|
|
9
|
+
DELIMITER = "."
|
|
10
|
+
NAMESPACE_VIOLATION_MESSAGE = """
|
|
11
|
+
{name} cannot start with {prefix}
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __call__(self, name: str, delimiter: str = DELIMITER):
|
|
15
|
+
if not name:
|
|
16
|
+
raise MlFoundryException("name should be a non empty string")
|
|
17
|
+
return _InternalNamespace.NAMESPACE + delimiter + name
|
|
18
|
+
|
|
19
|
+
def __truediv__(self, path: str):
|
|
20
|
+
return os.path.join(_InternalNamespace.NAMESPACE, path)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def _validate_name_not_using_namespace(name: typing.Optional[str], delimiter: str):
|
|
24
|
+
if name and name.startswith(_InternalNamespace.NAMESPACE + delimiter):
|
|
25
|
+
raise MlFoundryException(
|
|
26
|
+
_InternalNamespace.NAMESPACE_VIOLATION_MESSAGE.format(
|
|
27
|
+
name=name, prefix=_InternalNamespace.NAMESPACE + delimiter
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def validate_namespace_not_used(
|
|
32
|
+
self,
|
|
33
|
+
names: typing.Optional[typing.Union[str, typing.Iterable[str]]] = None,
|
|
34
|
+
delimiter: str = DELIMITER,
|
|
35
|
+
path: typing.Optional[str] = None,
|
|
36
|
+
):
|
|
37
|
+
if isinstance(names, str):
|
|
38
|
+
names = [names]
|
|
39
|
+
if names is not None:
|
|
40
|
+
for name_ in names:
|
|
41
|
+
self._validate_name_not_using_namespace(name_, delimiter)
|
|
42
|
+
if path:
|
|
43
|
+
prefix = os.path.normpath(os.path.join(_InternalNamespace.NAMESPACE, ""))
|
|
44
|
+
if os.path.normpath(path).startswith(prefix):
|
|
45
|
+
raise MlFoundryException(
|
|
46
|
+
_InternalNamespace.NAMESPACE_VIOLATION_MESSAGE.format(
|
|
47
|
+
name=path, prefix=prefix
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
NAMESPACE = _InternalNamespace()
|