polyaxon 2.1.0rc9__py3-none-any.whl → 2.6.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.
- polyaxon/_auxiliaries/default_scheduling.py +17 -7
- polyaxon/_auxiliaries/init.py +14 -6
- polyaxon/_auxiliaries/sidecar.py +10 -8
- polyaxon/_cli/artifacts.py +96 -11
- polyaxon/_cli/components.py +96 -11
- polyaxon/_cli/config.py +31 -0
- polyaxon/_cli/dashboard.py +12 -2
- polyaxon/_cli/init.py +1 -1
- polyaxon/_cli/models.py +96 -11
- polyaxon/_cli/operations.py +133 -58
- polyaxon/_cli/project_versions.py +139 -6
- polyaxon/_cli/projects.py +23 -9
- polyaxon/_cli/run.py +43 -9
- polyaxon/_cli/services/agent.py +2 -2
- polyaxon/_cli/version.py +4 -1
- polyaxon/_client/mixin.py +39 -0
- polyaxon/_client/project.py +218 -23
- polyaxon/_client/run.py +84 -27
- polyaxon/_compiler/contexts/contexts.py +4 -0
- polyaxon/_compiler/contexts/ray_job.py +4 -2
- polyaxon/_compiler/resolver/agent.py +22 -10
- polyaxon/_compiler/resolver/runtime.py +7 -3
- polyaxon/_constants/metadata.py +1 -0
- polyaxon/_contexts/keys.py +1 -0
- polyaxon/_contexts/paths.py +1 -1
- polyaxon/_deploy/operators/compose.py +1 -27
- polyaxon/_deploy/schemas/auth.py +3 -3
- polyaxon/_deploy/schemas/celery.py +10 -8
- polyaxon/_deploy/schemas/deployment.py +148 -115
- polyaxon/_deploy/schemas/email.py +8 -8
- polyaxon/_deploy/schemas/ingress.py +7 -7
- polyaxon/_deploy/schemas/intervals.py +2 -7
- polyaxon/_deploy/schemas/operators.py +8 -8
- polyaxon/_deploy/schemas/proxy.py +9 -8
- polyaxon/_deploy/schemas/rbac.py +1 -1
- polyaxon/_deploy/schemas/root_user.py +5 -5
- polyaxon/_deploy/schemas/security_context.py +25 -15
- polyaxon/_deploy/schemas/service.py +75 -66
- polyaxon/_deploy/schemas/ssl.py +3 -3
- polyaxon/_deploy/schemas/ui.py +10 -6
- polyaxon/_docker/builder/builder.py +4 -1
- polyaxon/_docker/converter/base/containers.py +4 -7
- polyaxon/_docker/converter/base/env_vars.py +5 -5
- polyaxon/_docker/converter/base/mounts.py +2 -2
- polyaxon/_docker/docker_types.py +57 -30
- polyaxon/_env_vars/getters/owner_entity.py +4 -2
- polyaxon/_env_vars/getters/project.py +4 -2
- polyaxon/_env_vars/getters/run.py +5 -2
- polyaxon/_env_vars/keys.py +3 -0
- polyaxon/_flow/__init__.py +3 -2
- polyaxon/_flow/builds/__init__.py +8 -8
- polyaxon/_flow/cache/__init__.py +4 -4
- polyaxon/_flow/component/base.py +25 -18
- polyaxon/_flow/component/component.py +4 -3
- polyaxon/_flow/early_stopping/__init__.py +1 -1
- polyaxon/_flow/early_stopping/policies.py +12 -10
- polyaxon/_flow/environment/__init__.py +43 -25
- polyaxon/_flow/events/__init__.py +1 -1
- polyaxon/_flow/hooks/__init__.py +11 -11
- polyaxon/_flow/init/__init__.py +41 -25
- polyaxon/_flow/io/io.py +57 -47
- polyaxon/_flow/joins/__init__.py +5 -5
- polyaxon/_flow/matrix/bayes.py +23 -17
- polyaxon/_flow/matrix/grid_search.py +16 -7
- polyaxon/_flow/matrix/hyperband.py +10 -10
- polyaxon/_flow/matrix/hyperopt.py +14 -9
- polyaxon/_flow/matrix/iterative.py +14 -8
- polyaxon/_flow/matrix/mapping.py +4 -4
- polyaxon/_flow/matrix/params.py +138 -77
- polyaxon/_flow/matrix/random_search.py +10 -5
- polyaxon/_flow/matrix/tuner.py +4 -4
- polyaxon/_flow/mounts/artifacts_mounts.py +1 -1
- polyaxon/_flow/notifications/__init__.py +1 -1
- polyaxon/_flow/operations/base.py +10 -8
- polyaxon/_flow/operations/compiled_operation.py +5 -4
- polyaxon/_flow/operations/operation.py +57 -41
- polyaxon/_flow/optimization/__init__.py +2 -2
- polyaxon/_flow/params/params.py +10 -9
- polyaxon/_flow/plugins/__init__.py +19 -13
- polyaxon/_flow/run/dag.py +12 -9
- polyaxon/_flow/run/dask/dask.py +4 -4
- polyaxon/_flow/run/dask/replica.py +17 -11
- polyaxon/_flow/run/job.py +17 -11
- polyaxon/_flow/run/kubeflow/mpi_job.py +10 -5
- polyaxon/_flow/run/kubeflow/mx_job.py +25 -9
- polyaxon/_flow/run/kubeflow/paddle_job.py +16 -9
- polyaxon/_flow/run/kubeflow/pytorch_job.py +24 -17
- polyaxon/_flow/run/kubeflow/replica.py +17 -11
- polyaxon/_flow/run/kubeflow/scheduling_policy.py +7 -5
- polyaxon/_flow/run/kubeflow/tf_job.py +15 -8
- polyaxon/_flow/run/kubeflow/xgboost_job.py +9 -4
- polyaxon/_flow/run/ray/ray.py +9 -6
- polyaxon/_flow/run/ray/replica.py +25 -16
- polyaxon/_flow/run/resources.py +14 -13
- polyaxon/_flow/run/service.py +4 -4
- polyaxon/_flow/schedules/cron.py +4 -4
- polyaxon/_flow/schedules/interval.py +4 -4
- polyaxon/_flow/templates/__init__.py +3 -3
- polyaxon/_flow/termination/__init__.py +3 -3
- polyaxon/_fs/async_manager.py +1 -1
- polyaxon/_fs/fs.py +1 -1
- polyaxon/_fs/watcher.py +26 -27
- polyaxon/_k8s/converter/base/base.py +2 -1
- polyaxon/_k8s/converter/base/main.py +1 -0
- polyaxon/_k8s/converter/common/accelerators.py +7 -4
- polyaxon/_k8s/converter/converters/ray_job.py +4 -2
- polyaxon/_k8s/custom_resources/dask_job.py +3 -0
- polyaxon/_k8s/custom_resources/kubeflow/common.py +4 -1
- polyaxon/_k8s/custom_resources/ray_job.py +3 -0
- polyaxon/_k8s/custom_resources/setter.py +1 -1
- polyaxon/_k8s/executor/async_executor.py +2 -0
- polyaxon/_k8s/k8s_validation.py +1 -1
- polyaxon/_k8s/logging/async_monitor.py +82 -11
- polyaxon/_k8s/manager/async_manager.py +15 -0
- polyaxon/_k8s/manager/manager.py +16 -1
- polyaxon/_local_process/__init__.py +0 -0
- polyaxon/_local_process/agent.py +6 -0
- polyaxon/_local_process/converter/__init__.py +1 -0
- polyaxon/_local_process/converter/base/__init__.py +1 -0
- polyaxon/_local_process/converter/base/base.py +140 -0
- polyaxon/_local_process/converter/base/containers.py +66 -0
- polyaxon/_local_process/converter/base/env_vars.py +253 -0
- polyaxon/_local_process/converter/base/init.py +414 -0
- polyaxon/_local_process/converter/base/main.py +74 -0
- polyaxon/_local_process/converter/base/mounts.py +82 -0
- polyaxon/_local_process/converter/converters/__init__.py +8 -0
- polyaxon/_local_process/converter/converters/job.py +40 -0
- polyaxon/_local_process/converter/converters/service.py +41 -0
- polyaxon/_local_process/converter/mixins.py +38 -0
- polyaxon/_local_process/executor.py +132 -0
- polyaxon/_local_process/process_types.py +42 -0
- polyaxon/_polyaxonfile/specs/compiled_operation.py +1 -1
- polyaxon/_polyaxonfile/specs/libs/parser.py +1 -1
- polyaxon/_polyaxonfile/specs/libs/validator.py +1 -1
- polyaxon/_polyaxonfile/specs/operation.py +1 -1
- polyaxon/_polyaxonfile/specs/sections.py +8 -0
- polyaxon/_pql/manager.py +1 -1
- polyaxon/_runner/agent/async_agent.py +25 -11
- polyaxon/_runner/agent/base_agent.py +19 -10
- polyaxon/_runner/agent/sync_agent.py +24 -10
- polyaxon/_runner/converter/converter.py +12 -4
- polyaxon/_runner/executor.py +1 -1
- polyaxon/_schemas/agent.py +69 -37
- polyaxon/_schemas/authentication.py +4 -4
- polyaxon/_schemas/base.py +26 -2
- polyaxon/_schemas/checks.py +3 -3
- polyaxon/_schemas/cli.py +4 -6
- polyaxon/_schemas/client.py +20 -18
- polyaxon/_schemas/compatibility.py +4 -4
- polyaxon/_schemas/container_resources.py +1 -1
- polyaxon/_schemas/home.py +3 -3
- polyaxon/_schemas/installation.py +13 -9
- polyaxon/_schemas/lifecycle.py +23 -23
- polyaxon/_schemas/log_handler.py +2 -2
- polyaxon/_schemas/services.py +26 -14
- polyaxon/_schemas/types/artifacts.py +3 -3
- polyaxon/_schemas/types/dockerfile.py +14 -12
- polyaxon/_schemas/types/event.py +2 -2
- polyaxon/_schemas/types/file.py +3 -3
- polyaxon/_schemas/types/git.py +12 -4
- polyaxon/_schemas/types/tensorboard.py +14 -8
- polyaxon/_schemas/user.py +3 -3
- polyaxon/_schemas/version.py +2 -2
- polyaxon/_sdk/api/agents_v1_api.py +222 -43
- polyaxon/_sdk/api/artifacts_stores_v1_api.py +3 -3
- polyaxon/_sdk/api/auth_v1_api.py +13 -13
- polyaxon/_sdk/api/connections_v1_api.py +15 -15
- polyaxon/_sdk/api/dashboards_v1_api.py +15 -15
- polyaxon/_sdk/api/organizations_v1_api.py +85 -85
- polyaxon/_sdk/api/presets_v1_api.py +15 -15
- polyaxon/_sdk/api/project_dashboards_v1_api.py +29 -29
- polyaxon/_sdk/api/project_searches_v1_api.py +29 -29
- polyaxon/_sdk/api/projects_v1_api.py +284 -107
- polyaxon/_sdk/api/queues_v1_api.py +19 -19
- polyaxon/_sdk/api/runs_v1_api.py +313 -359
- polyaxon/_sdk/api/searches_v1_api.py +15 -15
- polyaxon/_sdk/api/service_accounts_v1_api.py +31 -31
- polyaxon/_sdk/api/tags_v1_api.py +17 -17
- polyaxon/_sdk/api/teams_v1_api.py +2854 -402
- polyaxon/_sdk/api/users_v1_api.py +254 -78
- polyaxon/_sdk/api/versions_v1_api.py +7 -7
- polyaxon/_sdk/async_client/api_client.py +4 -0
- polyaxon/_sdk/schemas/__init__.py +1 -1
- polyaxon/_sdk/schemas/v1_activity.py +8 -8
- polyaxon/_sdk/schemas/v1_agent.py +18 -16
- polyaxon/_sdk/schemas/v1_agent_state_response.py +4 -4
- polyaxon/_sdk/schemas/v1_agent_state_response_agent_state.py +10 -10
- polyaxon/_sdk/schemas/v1_agent_status_body_request.py +3 -3
- polyaxon/_sdk/schemas/v1_analytics_spec.py +4 -4
- polyaxon/_sdk/schemas/v1_artifact_tree.py +3 -3
- polyaxon/_sdk/schemas/v1_auth.py +1 -1
- polyaxon/_sdk/schemas/v1_cloning.py +3 -3
- polyaxon/_sdk/schemas/v1_connection_response.py +9 -9
- polyaxon/_sdk/schemas/v1_dashboard.py +9 -9
- polyaxon/_sdk/schemas/v1_dashboard_spec.py +5 -1
- polyaxon/_sdk/schemas/v1_entities_tags.py +2 -2
- polyaxon/_sdk/schemas/v1_entities_transfer.py +2 -2
- polyaxon/_sdk/schemas/v1_entity_notification_body.py +7 -7
- polyaxon/_sdk/schemas/v1_entity_stage_body_request.py +5 -5
- polyaxon/_sdk/schemas/v1_entity_status_body_request.py +5 -5
- polyaxon/_sdk/schemas/v1_events_response.py +2 -2
- polyaxon/_sdk/schemas/v1_list_activities_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_agents_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_bookmarks_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_connections_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_dashboards_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_organization_members_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_organizations_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_presets_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_project_versions_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_projects_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_queues_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_run_artifacts_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_run_connections_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_run_edges_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_runs_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_searches_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_service_accounts_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_tags_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_team_members_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_teams_response.py +4 -4
- polyaxon/_sdk/schemas/v1_list_token_response.py +4 -4
- polyaxon/_sdk/schemas/v1_operation_body.py +8 -8
- polyaxon/_sdk/schemas/v1_organization.py +16 -16
- polyaxon/_sdk/schemas/v1_organization_member.py +6 -6
- polyaxon/_sdk/schemas/v1_password_change.py +3 -3
- polyaxon/_sdk/schemas/v1_pipeline.py +3 -3
- polyaxon/_sdk/schemas/v1_preset.py +16 -9
- polyaxon/_sdk/schemas/v1_project.py +17 -17
- polyaxon/_sdk/schemas/v1_project_settings.py +12 -10
- polyaxon/_sdk/schemas/v1_project_version.py +20 -20
- polyaxon/_sdk/schemas/v1_queue.py +12 -12
- polyaxon/_sdk/schemas/v1_run.py +38 -38
- polyaxon/_sdk/schemas/v1_run_connection.py +3 -3
- polyaxon/_sdk/schemas/v1_run_edge.py +5 -5
- polyaxon/_sdk/schemas/v1_run_edge_lineage.py +3 -3
- polyaxon/_sdk/schemas/v1_run_edges_graph.py +1 -1
- polyaxon/_sdk/schemas/v1_run_reference_catalog.py +4 -4
- polyaxon/_sdk/schemas/v1_run_settings.py +9 -9
- polyaxon/_sdk/schemas/v1_search.py +10 -10
- polyaxon/_sdk/schemas/v1_search_spec.py +14 -14
- polyaxon/_sdk/schemas/v1_section_spec.py +12 -7
- polyaxon/_sdk/schemas/v1_service_account.py +9 -9
- polyaxon/_sdk/schemas/v1_settings_catalog.py +4 -3
- polyaxon/_sdk/schemas/v1_tag.py +6 -6
- polyaxon/_sdk/schemas/v1_team.py +11 -8
- polyaxon/_sdk/schemas/v1_team_member.py +6 -6
- polyaxon/_sdk/schemas/v1_team_settings.py +2 -2
- polyaxon/_sdk/schemas/v1_token.py +10 -10
- polyaxon/_sdk/schemas/v1_trial_start.py +6 -6
- polyaxon/_sdk/schemas/v1_user.py +6 -7
- polyaxon/_sdk/schemas/v1_user_access.py +17 -0
- polyaxon/_sdk/schemas/v1_user_email.py +1 -1
- polyaxon/_sdk/schemas/v1_user_singup.py +5 -5
- polyaxon/_sdk/schemas/v1_uuids.py +1 -1
- polyaxon/_sidecar/container/__init__.py +39 -20
- polyaxon/_sidecar/container/monitors/logs.py +10 -13
- polyaxon/_sidecar/ignore.py +0 -1
- polyaxon/_utils/cli_constants.py +2 -0
- polyaxon/_utils/fqn_utils.py +25 -2
- polyaxon/_utils/test_utils.py +2 -1
- polyaxon/pkg.py +1 -1
- polyaxon/schemas.py +1 -1
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/METADATA +43 -43
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/RECORD +269 -252
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/WHEEL +1 -1
- polyaxon/_sdk/schemas/v1_project_user_access.py +0 -10
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/LICENSE +0 -0
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/entry_points.txt +0 -0
- {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,253 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from typing import Any, Iterable, List, Optional
|
4
|
+
|
5
|
+
import orjson
|
6
|
+
|
7
|
+
from clipped.utils.enums import get_enum_value
|
8
|
+
from clipped.utils.json import orjson_dumps, orjson_loads
|
9
|
+
from clipped.utils.lists import to_list
|
10
|
+
|
11
|
+
from polyaxon import settings
|
12
|
+
from polyaxon._connections import V1ConnectionResource
|
13
|
+
from polyaxon._env_vars.keys import (
|
14
|
+
ENV_KEYS_API_VERSION,
|
15
|
+
ENV_KEYS_AUTH_TOKEN,
|
16
|
+
ENV_KEYS_AUTHENTICATION_TYPE,
|
17
|
+
ENV_KEYS_HAS_PROCESS_SIDECAR,
|
18
|
+
ENV_KEYS_HEADER,
|
19
|
+
ENV_KEYS_HEADER_SERVICE,
|
20
|
+
ENV_KEYS_HOST,
|
21
|
+
ENV_KEYS_IS_MANAGED,
|
22
|
+
ENV_KEYS_K8S_NAMESPACE,
|
23
|
+
ENV_KEYS_K8S_NODE_NAME,
|
24
|
+
ENV_KEYS_K8S_POD_ID,
|
25
|
+
ENV_KEYS_LOG_LEVEL,
|
26
|
+
ENV_KEYS_SECRET_INTERNAL_TOKEN,
|
27
|
+
ENV_KEYS_SECRET_KEY,
|
28
|
+
)
|
29
|
+
from polyaxon._local_process import process_types
|
30
|
+
from polyaxon._runner.converter import BaseConverter
|
31
|
+
from polyaxon._services.headers import PolyaxonServiceHeaders
|
32
|
+
from polyaxon.api import VERSION_V1
|
33
|
+
from polyaxon.exceptions import PolyaxonConverterError
|
34
|
+
|
35
|
+
|
36
|
+
class EnvMixin(BaseConverter):
|
37
|
+
@staticmethod
|
38
|
+
def _get_env_var(name: str, value: Any) -> process_types.V1EnvVar:
|
39
|
+
if not isinstance(value, str):
|
40
|
+
try:
|
41
|
+
value = orjson_dumps(value)
|
42
|
+
except (ValueError, TypeError) as e:
|
43
|
+
raise PolyaxonConverterError(e)
|
44
|
+
|
45
|
+
return process_types.V1EnvVar.make((name, value))
|
46
|
+
|
47
|
+
@staticmethod
|
48
|
+
def _get_from_json_resource(
|
49
|
+
resource: V1ConnectionResource,
|
50
|
+
) -> List[process_types.V1EnvVar]:
|
51
|
+
if not resource or resource.items or resource.mount_path:
|
52
|
+
return []
|
53
|
+
|
54
|
+
secret = os.environ.get(resource.name)
|
55
|
+
if not secret:
|
56
|
+
return []
|
57
|
+
try:
|
58
|
+
secret_value = orjson_loads(secret)
|
59
|
+
except Exception as e:
|
60
|
+
raise PolyaxonConverterError from e
|
61
|
+
|
62
|
+
return [process_types.V1EnvVar.make(k) for k in (secret_value.items())]
|
63
|
+
|
64
|
+
@classmethod
|
65
|
+
def _get_env_from_json_resources(
|
66
|
+
cls,
|
67
|
+
resources: Iterable[V1ConnectionResource],
|
68
|
+
) -> List[process_types.V1EnvVar]:
|
69
|
+
resources = resources or []
|
70
|
+
results = []
|
71
|
+
for resource in resources:
|
72
|
+
results += cls._get_from_json_resource(resource=resource)
|
73
|
+
return [r for r in results if r]
|
74
|
+
|
75
|
+
@staticmethod
|
76
|
+
def _get_item_from_json_resource(
|
77
|
+
key: str, resource_ref_name: str
|
78
|
+
) -> Optional[process_types.V1EnvVar]:
|
79
|
+
secret = os.environ.get(resource_ref_name)
|
80
|
+
if not secret:
|
81
|
+
return None
|
82
|
+
try:
|
83
|
+
secret_value = orjson_loads(secret)
|
84
|
+
except orjson.JSONDecodeError:
|
85
|
+
return process_types.V1EnvVar.make((key, secret))
|
86
|
+
|
87
|
+
value = secret_value.get(key)
|
88
|
+
return process_types.V1EnvVar.make((key, value))
|
89
|
+
|
90
|
+
@classmethod
|
91
|
+
def _get_items_from_json_resource(
|
92
|
+
cls,
|
93
|
+
resource: V1ConnectionResource,
|
94
|
+
) -> List[process_types.V1EnvVar]:
|
95
|
+
items_from = []
|
96
|
+
if not resource or not resource.items:
|
97
|
+
return items_from
|
98
|
+
|
99
|
+
try:
|
100
|
+
secret_value = orjson_loads(resource.name)
|
101
|
+
except orjson.JSONDecodeError as e:
|
102
|
+
return items_from
|
103
|
+
|
104
|
+
for item in resource.items:
|
105
|
+
value = secret_value.get(item)
|
106
|
+
if value:
|
107
|
+
items_from.append(process_types.V1EnvVar.make((item, value)))
|
108
|
+
return items_from
|
109
|
+
|
110
|
+
@classmethod
|
111
|
+
def _get_env_vars_from_resources(
|
112
|
+
cls,
|
113
|
+
resources: Iterable[V1ConnectionResource],
|
114
|
+
) -> List[process_types.V1EnvVar]:
|
115
|
+
resources = resources or []
|
116
|
+
env_vars = []
|
117
|
+
for secret in resources:
|
118
|
+
env_vars += cls._get_items_from_json_resource(resource=secret)
|
119
|
+
return env_vars
|
120
|
+
|
121
|
+
@classmethod
|
122
|
+
def _get_env_vars_from_k8s_resources(
|
123
|
+
cls,
|
124
|
+
secrets: Iterable[V1ConnectionResource],
|
125
|
+
config_maps: Iterable[V1ConnectionResource],
|
126
|
+
) -> List[process_types.V1EnvVar]:
|
127
|
+
resources = to_list(secrets, check_none=True) + to_list(
|
128
|
+
config_maps, check_none=True
|
129
|
+
)
|
130
|
+
return cls._get_env_vars_from_resources(resources=resources)
|
131
|
+
|
132
|
+
@classmethod
|
133
|
+
def _get_additional_env_vars(cls) -> List[process_types.V1EnvVar]:
|
134
|
+
return [cls._get_env_var(name=ENV_KEYS_HAS_PROCESS_SIDECAR, value=True)]
|
135
|
+
|
136
|
+
@classmethod
|
137
|
+
def _get_base_env_vars(
|
138
|
+
cls,
|
139
|
+
namespace: str,
|
140
|
+
resource_name: str,
|
141
|
+
use_proxy_env_vars_use_in_ops: bool,
|
142
|
+
log_level: Optional[str] = None,
|
143
|
+
) -> List[process_types.V1EnvVar]:
|
144
|
+
env = [
|
145
|
+
cls._get_env_var(name=ENV_KEYS_K8S_NODE_NAME, value="process-agent"),
|
146
|
+
cls._get_env_var(name=ENV_KEYS_K8S_NAMESPACE, value=namespace),
|
147
|
+
cls._get_env_var(name=ENV_KEYS_K8S_POD_ID, value=resource_name),
|
148
|
+
]
|
149
|
+
if log_level:
|
150
|
+
env.append(cls._get_env_var(name=ENV_KEYS_LOG_LEVEL, value=log_level))
|
151
|
+
env += cls._get_proxy_env_vars(use_proxy_env_vars_use_in_ops)
|
152
|
+
return env
|
153
|
+
|
154
|
+
def _get_service_env_vars(
|
155
|
+
self,
|
156
|
+
service_header: str,
|
157
|
+
header: Optional[str] = PolyaxonServiceHeaders.SERVICE,
|
158
|
+
include_secret_key: bool = False,
|
159
|
+
include_internal_token: bool = False,
|
160
|
+
include_agent_token: bool = False,
|
161
|
+
authentication_type: Optional[str] = None,
|
162
|
+
external_host: bool = False,
|
163
|
+
log_level: Optional[str] = None,
|
164
|
+
polyaxon_default_secret_ref: Optional[str] = None,
|
165
|
+
polyaxon_agent_secret_ref: Optional[str] = None,
|
166
|
+
api_version: Optional[str] = None,
|
167
|
+
use_proxy_env_vars_use_in_ops: Optional[bool] = None,
|
168
|
+
) -> List[process_types.V1EnvVar]:
|
169
|
+
api_host = self.get_api_host(external_host)
|
170
|
+
polyaxon_default_secret_ref = (
|
171
|
+
polyaxon_default_secret_ref or settings.AGENT_CONFIG.app_secret_name
|
172
|
+
)
|
173
|
+
polyaxon_agent_secret_ref = (
|
174
|
+
polyaxon_agent_secret_ref or settings.AGENT_CONFIG.agent_secret_name
|
175
|
+
)
|
176
|
+
# TODO: Add support for local CLI auth
|
177
|
+
use_proxy_env_vars_use_in_ops = (
|
178
|
+
use_proxy_env_vars_use_in_ops
|
179
|
+
if use_proxy_env_vars_use_in_ops is not None
|
180
|
+
else settings.AGENT_CONFIG.use_proxy_env_vars_use_in_ops
|
181
|
+
)
|
182
|
+
api_version = api_version or VERSION_V1
|
183
|
+
env_vars = self._get_base_env_vars(
|
184
|
+
namespace=self.namespace,
|
185
|
+
resource_name=self.resource_name,
|
186
|
+
use_proxy_env_vars_use_in_ops=use_proxy_env_vars_use_in_ops,
|
187
|
+
) + [
|
188
|
+
self._get_env_var(name=ENV_KEYS_HOST, value=api_host),
|
189
|
+
self._get_env_var(name=ENV_KEYS_IS_MANAGED, value=True),
|
190
|
+
self._get_env_var(name=ENV_KEYS_API_VERSION, value=api_version),
|
191
|
+
self._get_run_instance_env_var(self.run_instance),
|
192
|
+
]
|
193
|
+
if log_level:
|
194
|
+
env_vars.append(self._get_env_var(name=ENV_KEYS_LOG_LEVEL, value=log_level))
|
195
|
+
if header:
|
196
|
+
env_vars.append(
|
197
|
+
self._get_env_var(
|
198
|
+
name=ENV_KEYS_HEADER,
|
199
|
+
value=PolyaxonServiceHeaders.get_header(header),
|
200
|
+
)
|
201
|
+
)
|
202
|
+
if service_header:
|
203
|
+
env_vars += to_list(
|
204
|
+
self._get_env_var(
|
205
|
+
name=ENV_KEYS_HEADER_SERVICE, value=get_enum_value(service_header)
|
206
|
+
),
|
207
|
+
)
|
208
|
+
if include_secret_key:
|
209
|
+
env_vars += to_list(
|
210
|
+
self._get_item_from_json_resource(
|
211
|
+
key=ENV_KEYS_SECRET_KEY,
|
212
|
+
resource_ref_name=polyaxon_default_secret_ref,
|
213
|
+
),
|
214
|
+
check_none=True,
|
215
|
+
)
|
216
|
+
internal = False
|
217
|
+
if include_internal_token and polyaxon_default_secret_ref:
|
218
|
+
internal = True
|
219
|
+
env_vars += to_list(
|
220
|
+
self._get_item_from_json_resource(
|
221
|
+
key=ENV_KEYS_SECRET_INTERNAL_TOKEN,
|
222
|
+
resource_ref_name=polyaxon_default_secret_ref,
|
223
|
+
),
|
224
|
+
check_none=True,
|
225
|
+
)
|
226
|
+
if include_agent_token:
|
227
|
+
if internal:
|
228
|
+
raise PolyaxonConverterError(
|
229
|
+
"A service cannot have internal token and agent token."
|
230
|
+
)
|
231
|
+
if polyaxon_agent_secret_ref:
|
232
|
+
env_vars += to_list(
|
233
|
+
self._get_item_from_json_resource(
|
234
|
+
key=ENV_KEYS_AUTH_TOKEN,
|
235
|
+
resource_ref_name=polyaxon_agent_secret_ref,
|
236
|
+
),
|
237
|
+
check_none=True,
|
238
|
+
)
|
239
|
+
elif settings.CLIENT_CONFIG.token:
|
240
|
+
env_vars += to_list(
|
241
|
+
self._get_env_var(
|
242
|
+
name=ENV_KEYS_AUTH_TOKEN, value=settings.CLIENT_CONFIG.token
|
243
|
+
),
|
244
|
+
check_none=True,
|
245
|
+
)
|
246
|
+
if authentication_type:
|
247
|
+
env_vars += to_list(
|
248
|
+
self._get_env_var(
|
249
|
+
name=ENV_KEYS_AUTHENTICATION_TYPE, value=authentication_type
|
250
|
+
),
|
251
|
+
check_none=True,
|
252
|
+
)
|
253
|
+
return env_vars
|
@@ -0,0 +1,414 @@
|
|
1
|
+
from typing import Any, List, Optional, Tuple, Union
|
2
|
+
|
3
|
+
from clipped.utils.enums import get_enum_value
|
4
|
+
from clipped.utils.lists import to_list
|
5
|
+
|
6
|
+
from polyaxon._auxiliaries import V1PolyaxonInitContainer
|
7
|
+
from polyaxon._connections import V1Connection, V1ConnectionKind
|
8
|
+
from polyaxon._constants.globals import DEFAULT
|
9
|
+
from polyaxon._containers.names import (
|
10
|
+
INIT_ARTIFACTS_CONTAINER_PREFIX,
|
11
|
+
INIT_AUTH_CONTAINER,
|
12
|
+
INIT_CUSTOM_CONTAINER_PREFIX,
|
13
|
+
INIT_DOCKERFILE_CONTAINER_PREFIX,
|
14
|
+
INIT_FILE_CONTAINER_PREFIX,
|
15
|
+
INIT_GIT_CONTAINER_PREFIX,
|
16
|
+
INIT_TENSORBOARD_CONTAINER_PREFIX,
|
17
|
+
generate_container_name,
|
18
|
+
)
|
19
|
+
from polyaxon._contexts import paths as ctx_paths
|
20
|
+
from polyaxon._env_vars.keys import ENV_KEYS_SSH_PATH
|
21
|
+
from polyaxon._flow import V1Plugins
|
22
|
+
from polyaxon._local_process import process_types
|
23
|
+
from polyaxon._runner.converter import BaseConverter as _BaseConverter
|
24
|
+
from polyaxon._runner.converter.init.artifacts import init_artifact_context_args
|
25
|
+
from polyaxon._runner.converter.init.file import FILE_INIT_COMMAND, get_file_init_args
|
26
|
+
from polyaxon._runner.converter.init.git import REPO_INIT_COMMAND, get_repo_context_args
|
27
|
+
from polyaxon._runner.converter.init.store import get_volume_args
|
28
|
+
from polyaxon._runner.converter.init.tensorboard import (
|
29
|
+
TENSORBOARD_INIT_COMMAND,
|
30
|
+
get_tensorboard_args,
|
31
|
+
)
|
32
|
+
from polyaxon._schemas.types import (
|
33
|
+
V1ArtifactsType,
|
34
|
+
V1DockerfileType,
|
35
|
+
V1FileType,
|
36
|
+
V1TensorboardType,
|
37
|
+
)
|
38
|
+
from polyaxon.exceptions import PolyaxonConverterError
|
39
|
+
|
40
|
+
|
41
|
+
class InitConverter(_BaseConverter):
|
42
|
+
@classmethod
|
43
|
+
def _get_base_store_container(
|
44
|
+
cls,
|
45
|
+
container: Optional[process_types.V1Container],
|
46
|
+
container_name: str,
|
47
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
48
|
+
store: V1Connection,
|
49
|
+
env: List[process_types.V1EnvVar],
|
50
|
+
env_from: List[Any],
|
51
|
+
args: List[str],
|
52
|
+
command: Optional[List[str]] = None,
|
53
|
+
**kwargs
|
54
|
+
) -> Optional[process_types.V1Container]:
|
55
|
+
env = env or []
|
56
|
+
|
57
|
+
# Artifact store needs to allow init the contexts as well, so the store is not required
|
58
|
+
if not store:
|
59
|
+
raise PolyaxonConverterError("Init store container requires a store")
|
60
|
+
|
61
|
+
if store.is_bucket:
|
62
|
+
secret = store.secret
|
63
|
+
env = env + to_list(
|
64
|
+
cls._get_items_from_json_resource(resource=secret), check_none=True
|
65
|
+
)
|
66
|
+
config_map = store.config_map
|
67
|
+
env = env + to_list(
|
68
|
+
cls._get_from_json_resource(resource=config_map),
|
69
|
+
check_none=True,
|
70
|
+
)
|
71
|
+
# Add connections catalog env vars information
|
72
|
+
connection_env = cls._get_connections_catalog_env_var(connections=[store])
|
73
|
+
if connection_env:
|
74
|
+
env.append(connection_env)
|
75
|
+
|
76
|
+
return cls._patch_container(
|
77
|
+
container=container,
|
78
|
+
name=container_name,
|
79
|
+
command=command or ["/bin/sh", "-c"],
|
80
|
+
args=args,
|
81
|
+
env=env,
|
82
|
+
)
|
83
|
+
|
84
|
+
@classmethod
|
85
|
+
def _get_custom_init_container(
|
86
|
+
cls,
|
87
|
+
connection: V1Connection,
|
88
|
+
plugins: V1Plugins,
|
89
|
+
container: Optional[process_types.V1Container],
|
90
|
+
run_path: str,
|
91
|
+
env: List[process_types.V1EnvVar] = None,
|
92
|
+
mount_path: Optional[str] = None,
|
93
|
+
) -> process_types.V1Container:
|
94
|
+
if not connection:
|
95
|
+
raise PolyaxonConverterError(
|
96
|
+
"A connection is required to create a repo context."
|
97
|
+
)
|
98
|
+
|
99
|
+
env = to_list(env, check_none=True)
|
100
|
+
secret = connection.secret
|
101
|
+
if secret:
|
102
|
+
env += to_list(
|
103
|
+
cls._get_from_json_resource(resource=secret), check_none=True
|
104
|
+
)
|
105
|
+
|
106
|
+
# Add connections catalog env vars information
|
107
|
+
connection_env = cls._get_connections_catalog_env_var(connections=[connection])
|
108
|
+
if connection_env:
|
109
|
+
env.append(connection_env)
|
110
|
+
connection_env = cls._get_connection_env_var(connection=connection)
|
111
|
+
if connection_env:
|
112
|
+
env.append(connection_env)
|
113
|
+
config_map = connection.config_map
|
114
|
+
if config_map:
|
115
|
+
env += to_list(
|
116
|
+
cls._get_from_json_resource(resource=config_map),
|
117
|
+
check_none=True,
|
118
|
+
)
|
119
|
+
container_name = container.name or generate_container_name(
|
120
|
+
INIT_CUSTOM_CONTAINER_PREFIX, connection.name
|
121
|
+
)
|
122
|
+
return cls._patch_container(
|
123
|
+
container=container,
|
124
|
+
name=container_name,
|
125
|
+
env=env,
|
126
|
+
)
|
127
|
+
|
128
|
+
@classmethod
|
129
|
+
def _get_dockerfile_init_container(
|
130
|
+
cls,
|
131
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
132
|
+
dockerfile_args: V1DockerfileType,
|
133
|
+
plugins: V1Plugins,
|
134
|
+
run_path: str,
|
135
|
+
run_instance: str,
|
136
|
+
container: Optional[process_types.V1Container] = None,
|
137
|
+
env: List[process_types.V1EnvVar] = None,
|
138
|
+
mount_path: Optional[str] = None,
|
139
|
+
) -> process_types.V1Container:
|
140
|
+
env = to_list(env, check_none=True)
|
141
|
+
env = env + [cls._get_run_instance_env_var(run_instance)]
|
142
|
+
|
143
|
+
container_name = generate_container_name(INIT_DOCKERFILE_CONTAINER_PREFIX)
|
144
|
+
if not container:
|
145
|
+
container = cls._new_container(name=container_name)
|
146
|
+
|
147
|
+
mount_path = mount_path or ctx_paths.CONTEXT_MOUNT_ARTIFACTS
|
148
|
+
|
149
|
+
return cls._patch_container(
|
150
|
+
container=container,
|
151
|
+
name=container_name,
|
152
|
+
image=polyaxon_init.get_image(),
|
153
|
+
image_pull_policy=polyaxon_init.image_pull_policy,
|
154
|
+
command=["polyaxon", "docker", "generate"],
|
155
|
+
args=[
|
156
|
+
"--build-context={}".format(dockerfile_args.to_json()),
|
157
|
+
"--destination={}".format(mount_path),
|
158
|
+
"--copy-path={}".format(
|
159
|
+
ctx_paths.CONTEXT_MOUNT_RUN_OUTPUTS_FORMAT.format(run_path)
|
160
|
+
),
|
161
|
+
"--track",
|
162
|
+
],
|
163
|
+
env=env,
|
164
|
+
)
|
165
|
+
|
166
|
+
@classmethod
|
167
|
+
def _get_file_init_container(
|
168
|
+
cls,
|
169
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
170
|
+
file_args: V1FileType,
|
171
|
+
plugins: V1Plugins,
|
172
|
+
run_path: str,
|
173
|
+
run_instance: str,
|
174
|
+
container: Optional[process_types.V1Container] = None,
|
175
|
+
env: List[process_types.V1EnvVar] = None,
|
176
|
+
mount_path: Optional[str] = None,
|
177
|
+
) -> process_types.V1Container:
|
178
|
+
env = to_list(env, check_none=True)
|
179
|
+
env = env + [cls._get_run_instance_env_var(run_instance)]
|
180
|
+
|
181
|
+
container_name = generate_container_name(INIT_FILE_CONTAINER_PREFIX)
|
182
|
+
if not container:
|
183
|
+
container = cls._new_container(name=container_name)
|
184
|
+
|
185
|
+
mount_path = mount_path or ctx_paths.CONTEXT_MOUNT_ARTIFACTS
|
186
|
+
|
187
|
+
file_args.filename = file_args.filename or "file"
|
188
|
+
return cls._patch_container(
|
189
|
+
container=container,
|
190
|
+
name=container_name,
|
191
|
+
image=polyaxon_init.get_image(),
|
192
|
+
image_pull_policy=polyaxon_init.image_pull_policy,
|
193
|
+
command=FILE_INIT_COMMAND,
|
194
|
+
args=get_file_init_args(
|
195
|
+
file_args=file_args, run_path=run_path, mount_path=mount_path
|
196
|
+
),
|
197
|
+
env=env,
|
198
|
+
)
|
199
|
+
|
200
|
+
@classmethod
|
201
|
+
def _get_git_init_container(
|
202
|
+
cls,
|
203
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
204
|
+
connection: V1Connection,
|
205
|
+
plugins: V1Plugins,
|
206
|
+
run_path: str,
|
207
|
+
container: Optional[process_types.V1Container] = None,
|
208
|
+
env: List[process_types.V1EnvVar] = None,
|
209
|
+
mount_path: Optional[str] = None,
|
210
|
+
track: bool = False,
|
211
|
+
) -> process_types.V1Container:
|
212
|
+
if not connection:
|
213
|
+
raise PolyaxonConverterError(
|
214
|
+
"A connection is required to create a repo context."
|
215
|
+
)
|
216
|
+
container_name = generate_container_name(
|
217
|
+
INIT_GIT_CONTAINER_PREFIX, connection.name
|
218
|
+
)
|
219
|
+
if not container:
|
220
|
+
container = cls._new_container(name=container_name)
|
221
|
+
|
222
|
+
mount_path = mount_path or ctx_paths.CONTEXT_MOUNT_ARTIFACTS
|
223
|
+
|
224
|
+
env = to_list(env, check_none=True)
|
225
|
+
env_from = []
|
226
|
+
secret = connection.secret
|
227
|
+
if secret:
|
228
|
+
env += to_list(
|
229
|
+
cls._get_from_json_resource(resource=secret), check_none=True
|
230
|
+
)
|
231
|
+
env_from += to_list(
|
232
|
+
cls._get_env_from_secret(secret=secret), check_none=True
|
233
|
+
)
|
234
|
+
|
235
|
+
# Add connections catalog env vars information
|
236
|
+
env += to_list(
|
237
|
+
cls._get_connections_catalog_env_var(connections=[connection]),
|
238
|
+
check_none=True,
|
239
|
+
)
|
240
|
+
env += to_list(
|
241
|
+
cls._get_connection_env_var(connection=connection), check_none=True
|
242
|
+
)
|
243
|
+
# Add special handling to auto-inject ssh mount path
|
244
|
+
if connection.kind == V1ConnectionKind.SSH and secret.mount_path:
|
245
|
+
env += [cls._get_env_var(ENV_KEYS_SSH_PATH, secret.mount_path)]
|
246
|
+
config_map = connection.config_map
|
247
|
+
if config_map:
|
248
|
+
env += to_list(
|
249
|
+
cls._get_from_json_resource(resource=config_map),
|
250
|
+
check_none=True,
|
251
|
+
)
|
252
|
+
env_from += to_list(
|
253
|
+
cls._get_env_from_config_map(config_map=config_map),
|
254
|
+
check_none=True,
|
255
|
+
)
|
256
|
+
args = get_repo_context_args(
|
257
|
+
name=connection.name,
|
258
|
+
# Handle the case of custom connection
|
259
|
+
url=getattr(connection.schema_, "url", None),
|
260
|
+
revision=getattr(connection.schema_, "revision", None),
|
261
|
+
flags=getattr(connection.schema_, "flags", None),
|
262
|
+
mount_path=mount_path,
|
263
|
+
connection=connection.name if track else None,
|
264
|
+
)
|
265
|
+
return cls._patch_container(
|
266
|
+
container=container,
|
267
|
+
name=container_name,
|
268
|
+
image=polyaxon_init.get_image(),
|
269
|
+
image_pull_policy=polyaxon_init.image_pull_policy,
|
270
|
+
command=REPO_INIT_COMMAND,
|
271
|
+
args=args,
|
272
|
+
env=env,
|
273
|
+
env_from=env_from,
|
274
|
+
)
|
275
|
+
|
276
|
+
@classmethod
|
277
|
+
def _get_store_init_container(
|
278
|
+
cls,
|
279
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
280
|
+
connection: V1Connection,
|
281
|
+
artifacts: V1ArtifactsType,
|
282
|
+
paths: Union[List[str], List[Tuple[str, str]]],
|
283
|
+
run_path: str,
|
284
|
+
container: Optional[process_types.V1Container] = None,
|
285
|
+
env: List[process_types.V1EnvVar] = None,
|
286
|
+
mount_path: Optional[str] = None,
|
287
|
+
is_default_artifacts_store: bool = False,
|
288
|
+
) -> process_types.V1Container:
|
289
|
+
container_name = generate_container_name(
|
290
|
+
INIT_ARTIFACTS_CONTAINER_PREFIX, connection.name
|
291
|
+
)
|
292
|
+
if not container:
|
293
|
+
container = cls._new_container(name=container_name)
|
294
|
+
|
295
|
+
mount_path = mount_path or (
|
296
|
+
ctx_paths.CONTEXT_MOUNT_ARTIFACTS
|
297
|
+
if is_default_artifacts_store
|
298
|
+
else ctx_paths.CONTEXT_MOUNT_ARTIFACTS_FORMAT.format(connection.name)
|
299
|
+
)
|
300
|
+
|
301
|
+
return cls._get_base_store_container(
|
302
|
+
container=container,
|
303
|
+
container_name=container_name,
|
304
|
+
polyaxon_init=polyaxon_init,
|
305
|
+
store=connection,
|
306
|
+
env=env,
|
307
|
+
env_from=[],
|
308
|
+
args=[
|
309
|
+
get_volume_args(
|
310
|
+
store=connection,
|
311
|
+
mount_path=mount_path,
|
312
|
+
artifacts=artifacts,
|
313
|
+
paths=paths,
|
314
|
+
)
|
315
|
+
],
|
316
|
+
)
|
317
|
+
|
318
|
+
@classmethod
|
319
|
+
def _get_tensorboard_init_container(
|
320
|
+
cls,
|
321
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
322
|
+
artifacts_store: V1Connection,
|
323
|
+
tb_args: V1TensorboardType,
|
324
|
+
plugins: V1Plugins,
|
325
|
+
run_path: str,
|
326
|
+
run_instance: str,
|
327
|
+
container: Optional[process_types.V1Container] = None,
|
328
|
+
env: List[process_types.V1EnvVar] = None,
|
329
|
+
mount_path: Optional[str] = None,
|
330
|
+
) -> process_types.V1Container:
|
331
|
+
env = to_list(env, check_none=True)
|
332
|
+
env = env + [cls._get_run_instance_env_var(run_instance)]
|
333
|
+
|
334
|
+
container_name = generate_container_name(INIT_TENSORBOARD_CONTAINER_PREFIX)
|
335
|
+
if not container:
|
336
|
+
container = cls._new_container(name=container_name)
|
337
|
+
|
338
|
+
mount_path = mount_path or ctx_paths.CONTEXT_MOUNT_ARTIFACTS
|
339
|
+
|
340
|
+
args = get_tensorboard_args(
|
341
|
+
tb_args=tb_args,
|
342
|
+
context_from=artifacts_store.store_path,
|
343
|
+
context_to=mount_path,
|
344
|
+
connection_kind=get_enum_value(artifacts_store.kind),
|
345
|
+
)
|
346
|
+
|
347
|
+
return cls._get_base_store_container(
|
348
|
+
container=container,
|
349
|
+
container_name=container_name,
|
350
|
+
polyaxon_init=polyaxon_init,
|
351
|
+
store=artifacts_store,
|
352
|
+
command=TENSORBOARD_INIT_COMMAND,
|
353
|
+
args=args,
|
354
|
+
env=env,
|
355
|
+
env_from=[],
|
356
|
+
)
|
357
|
+
|
358
|
+
@classmethod
|
359
|
+
def _get_auth_context_init_container(
|
360
|
+
cls,
|
361
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
362
|
+
run_path: str,
|
363
|
+
env: Optional[List[process_types.V1EnvVar]] = None,
|
364
|
+
) -> process_types.V1Container:
|
365
|
+
env = to_list(env, check_none=True)
|
366
|
+
container = process_types.V1Container(
|
367
|
+
name=INIT_AUTH_CONTAINER,
|
368
|
+
image=polyaxon_init.get_image(),
|
369
|
+
command=["polyaxon", "initializer", "auth"],
|
370
|
+
env=env,
|
371
|
+
)
|
372
|
+
return cls._patch_container(container)
|
373
|
+
|
374
|
+
@classmethod
|
375
|
+
def _get_artifacts_path_init_container(
|
376
|
+
cls,
|
377
|
+
polyaxon_init: V1PolyaxonInitContainer,
|
378
|
+
artifacts_store: V1Connection,
|
379
|
+
run_path: str,
|
380
|
+
auto_resume: bool,
|
381
|
+
env: Optional[List[process_types.V1EnvVar]] = None,
|
382
|
+
) -> process_types.V1Container:
|
383
|
+
if not artifacts_store:
|
384
|
+
raise PolyaxonConverterError("Init artifacts container requires a store.")
|
385
|
+
|
386
|
+
env = to_list(env, check_none=True)
|
387
|
+
init_args = init_artifact_context_args(run_path=run_path)
|
388
|
+
if auto_resume:
|
389
|
+
init_args.append(
|
390
|
+
get_volume_args(
|
391
|
+
store=artifacts_store,
|
392
|
+
mount_path=ctx_paths.CONTEXT_MOUNT_ARTIFACTS,
|
393
|
+
artifacts=V1ArtifactsType(dirs=[run_path]),
|
394
|
+
paths=None,
|
395
|
+
sync_fw=True,
|
396
|
+
)
|
397
|
+
)
|
398
|
+
|
399
|
+
container_name = generate_container_name(
|
400
|
+
INIT_ARTIFACTS_CONTAINER_PREFIX, DEFAULT, False
|
401
|
+
)
|
402
|
+
container = cls._new_container(name=container_name)
|
403
|
+
|
404
|
+
return cls._get_base_store_container(
|
405
|
+
container_name=container_name,
|
406
|
+
container=container,
|
407
|
+
polyaxon_init=polyaxon_init,
|
408
|
+
store=artifacts_store,
|
409
|
+
env=env,
|
410
|
+
env_from=[],
|
411
|
+
# If we are dealing with a volume we need to make sure the path exists for the user
|
412
|
+
# We also clean the path if this is not a resume run
|
413
|
+
args=[" ".join(init_args)],
|
414
|
+
)
|