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.
Files changed (270) hide show
  1. polyaxon/_auxiliaries/default_scheduling.py +17 -7
  2. polyaxon/_auxiliaries/init.py +14 -6
  3. polyaxon/_auxiliaries/sidecar.py +10 -8
  4. polyaxon/_cli/artifacts.py +96 -11
  5. polyaxon/_cli/components.py +96 -11
  6. polyaxon/_cli/config.py +31 -0
  7. polyaxon/_cli/dashboard.py +12 -2
  8. polyaxon/_cli/init.py +1 -1
  9. polyaxon/_cli/models.py +96 -11
  10. polyaxon/_cli/operations.py +133 -58
  11. polyaxon/_cli/project_versions.py +139 -6
  12. polyaxon/_cli/projects.py +23 -9
  13. polyaxon/_cli/run.py +43 -9
  14. polyaxon/_cli/services/agent.py +2 -2
  15. polyaxon/_cli/version.py +4 -1
  16. polyaxon/_client/mixin.py +39 -0
  17. polyaxon/_client/project.py +218 -23
  18. polyaxon/_client/run.py +84 -27
  19. polyaxon/_compiler/contexts/contexts.py +4 -0
  20. polyaxon/_compiler/contexts/ray_job.py +4 -2
  21. polyaxon/_compiler/resolver/agent.py +22 -10
  22. polyaxon/_compiler/resolver/runtime.py +7 -3
  23. polyaxon/_constants/metadata.py +1 -0
  24. polyaxon/_contexts/keys.py +1 -0
  25. polyaxon/_contexts/paths.py +1 -1
  26. polyaxon/_deploy/operators/compose.py +1 -27
  27. polyaxon/_deploy/schemas/auth.py +3 -3
  28. polyaxon/_deploy/schemas/celery.py +10 -8
  29. polyaxon/_deploy/schemas/deployment.py +148 -115
  30. polyaxon/_deploy/schemas/email.py +8 -8
  31. polyaxon/_deploy/schemas/ingress.py +7 -7
  32. polyaxon/_deploy/schemas/intervals.py +2 -7
  33. polyaxon/_deploy/schemas/operators.py +8 -8
  34. polyaxon/_deploy/schemas/proxy.py +9 -8
  35. polyaxon/_deploy/schemas/rbac.py +1 -1
  36. polyaxon/_deploy/schemas/root_user.py +5 -5
  37. polyaxon/_deploy/schemas/security_context.py +25 -15
  38. polyaxon/_deploy/schemas/service.py +75 -66
  39. polyaxon/_deploy/schemas/ssl.py +3 -3
  40. polyaxon/_deploy/schemas/ui.py +10 -6
  41. polyaxon/_docker/builder/builder.py +4 -1
  42. polyaxon/_docker/converter/base/containers.py +4 -7
  43. polyaxon/_docker/converter/base/env_vars.py +5 -5
  44. polyaxon/_docker/converter/base/mounts.py +2 -2
  45. polyaxon/_docker/docker_types.py +57 -30
  46. polyaxon/_env_vars/getters/owner_entity.py +4 -2
  47. polyaxon/_env_vars/getters/project.py +4 -2
  48. polyaxon/_env_vars/getters/run.py +5 -2
  49. polyaxon/_env_vars/keys.py +3 -0
  50. polyaxon/_flow/__init__.py +3 -2
  51. polyaxon/_flow/builds/__init__.py +8 -8
  52. polyaxon/_flow/cache/__init__.py +4 -4
  53. polyaxon/_flow/component/base.py +25 -18
  54. polyaxon/_flow/component/component.py +4 -3
  55. polyaxon/_flow/early_stopping/__init__.py +1 -1
  56. polyaxon/_flow/early_stopping/policies.py +12 -10
  57. polyaxon/_flow/environment/__init__.py +43 -25
  58. polyaxon/_flow/events/__init__.py +1 -1
  59. polyaxon/_flow/hooks/__init__.py +11 -11
  60. polyaxon/_flow/init/__init__.py +41 -25
  61. polyaxon/_flow/io/io.py +57 -47
  62. polyaxon/_flow/joins/__init__.py +5 -5
  63. polyaxon/_flow/matrix/bayes.py +23 -17
  64. polyaxon/_flow/matrix/grid_search.py +16 -7
  65. polyaxon/_flow/matrix/hyperband.py +10 -10
  66. polyaxon/_flow/matrix/hyperopt.py +14 -9
  67. polyaxon/_flow/matrix/iterative.py +14 -8
  68. polyaxon/_flow/matrix/mapping.py +4 -4
  69. polyaxon/_flow/matrix/params.py +138 -77
  70. polyaxon/_flow/matrix/random_search.py +10 -5
  71. polyaxon/_flow/matrix/tuner.py +4 -4
  72. polyaxon/_flow/mounts/artifacts_mounts.py +1 -1
  73. polyaxon/_flow/notifications/__init__.py +1 -1
  74. polyaxon/_flow/operations/base.py +10 -8
  75. polyaxon/_flow/operations/compiled_operation.py +5 -4
  76. polyaxon/_flow/operations/operation.py +57 -41
  77. polyaxon/_flow/optimization/__init__.py +2 -2
  78. polyaxon/_flow/params/params.py +10 -9
  79. polyaxon/_flow/plugins/__init__.py +19 -13
  80. polyaxon/_flow/run/dag.py +12 -9
  81. polyaxon/_flow/run/dask/dask.py +4 -4
  82. polyaxon/_flow/run/dask/replica.py +17 -11
  83. polyaxon/_flow/run/job.py +17 -11
  84. polyaxon/_flow/run/kubeflow/mpi_job.py +10 -5
  85. polyaxon/_flow/run/kubeflow/mx_job.py +25 -9
  86. polyaxon/_flow/run/kubeflow/paddle_job.py +16 -9
  87. polyaxon/_flow/run/kubeflow/pytorch_job.py +24 -17
  88. polyaxon/_flow/run/kubeflow/replica.py +17 -11
  89. polyaxon/_flow/run/kubeflow/scheduling_policy.py +7 -5
  90. polyaxon/_flow/run/kubeflow/tf_job.py +15 -8
  91. polyaxon/_flow/run/kubeflow/xgboost_job.py +9 -4
  92. polyaxon/_flow/run/ray/ray.py +9 -6
  93. polyaxon/_flow/run/ray/replica.py +25 -16
  94. polyaxon/_flow/run/resources.py +14 -13
  95. polyaxon/_flow/run/service.py +4 -4
  96. polyaxon/_flow/schedules/cron.py +4 -4
  97. polyaxon/_flow/schedules/interval.py +4 -4
  98. polyaxon/_flow/templates/__init__.py +3 -3
  99. polyaxon/_flow/termination/__init__.py +3 -3
  100. polyaxon/_fs/async_manager.py +1 -1
  101. polyaxon/_fs/fs.py +1 -1
  102. polyaxon/_fs/watcher.py +26 -27
  103. polyaxon/_k8s/converter/base/base.py +2 -1
  104. polyaxon/_k8s/converter/base/main.py +1 -0
  105. polyaxon/_k8s/converter/common/accelerators.py +7 -4
  106. polyaxon/_k8s/converter/converters/ray_job.py +4 -2
  107. polyaxon/_k8s/custom_resources/dask_job.py +3 -0
  108. polyaxon/_k8s/custom_resources/kubeflow/common.py +4 -1
  109. polyaxon/_k8s/custom_resources/ray_job.py +3 -0
  110. polyaxon/_k8s/custom_resources/setter.py +1 -1
  111. polyaxon/_k8s/executor/async_executor.py +2 -0
  112. polyaxon/_k8s/k8s_validation.py +1 -1
  113. polyaxon/_k8s/logging/async_monitor.py +82 -11
  114. polyaxon/_k8s/manager/async_manager.py +15 -0
  115. polyaxon/_k8s/manager/manager.py +16 -1
  116. polyaxon/_local_process/__init__.py +0 -0
  117. polyaxon/_local_process/agent.py +6 -0
  118. polyaxon/_local_process/converter/__init__.py +1 -0
  119. polyaxon/_local_process/converter/base/__init__.py +1 -0
  120. polyaxon/_local_process/converter/base/base.py +140 -0
  121. polyaxon/_local_process/converter/base/containers.py +66 -0
  122. polyaxon/_local_process/converter/base/env_vars.py +253 -0
  123. polyaxon/_local_process/converter/base/init.py +414 -0
  124. polyaxon/_local_process/converter/base/main.py +74 -0
  125. polyaxon/_local_process/converter/base/mounts.py +82 -0
  126. polyaxon/_local_process/converter/converters/__init__.py +8 -0
  127. polyaxon/_local_process/converter/converters/job.py +40 -0
  128. polyaxon/_local_process/converter/converters/service.py +41 -0
  129. polyaxon/_local_process/converter/mixins.py +38 -0
  130. polyaxon/_local_process/executor.py +132 -0
  131. polyaxon/_local_process/process_types.py +42 -0
  132. polyaxon/_polyaxonfile/specs/compiled_operation.py +1 -1
  133. polyaxon/_polyaxonfile/specs/libs/parser.py +1 -1
  134. polyaxon/_polyaxonfile/specs/libs/validator.py +1 -1
  135. polyaxon/_polyaxonfile/specs/operation.py +1 -1
  136. polyaxon/_polyaxonfile/specs/sections.py +8 -0
  137. polyaxon/_pql/manager.py +1 -1
  138. polyaxon/_runner/agent/async_agent.py +25 -11
  139. polyaxon/_runner/agent/base_agent.py +19 -10
  140. polyaxon/_runner/agent/sync_agent.py +24 -10
  141. polyaxon/_runner/converter/converter.py +12 -4
  142. polyaxon/_runner/executor.py +1 -1
  143. polyaxon/_schemas/agent.py +69 -37
  144. polyaxon/_schemas/authentication.py +4 -4
  145. polyaxon/_schemas/base.py +26 -2
  146. polyaxon/_schemas/checks.py +3 -3
  147. polyaxon/_schemas/cli.py +4 -6
  148. polyaxon/_schemas/client.py +20 -18
  149. polyaxon/_schemas/compatibility.py +4 -4
  150. polyaxon/_schemas/container_resources.py +1 -1
  151. polyaxon/_schemas/home.py +3 -3
  152. polyaxon/_schemas/installation.py +13 -9
  153. polyaxon/_schemas/lifecycle.py +23 -23
  154. polyaxon/_schemas/log_handler.py +2 -2
  155. polyaxon/_schemas/services.py +26 -14
  156. polyaxon/_schemas/types/artifacts.py +3 -3
  157. polyaxon/_schemas/types/dockerfile.py +14 -12
  158. polyaxon/_schemas/types/event.py +2 -2
  159. polyaxon/_schemas/types/file.py +3 -3
  160. polyaxon/_schemas/types/git.py +12 -4
  161. polyaxon/_schemas/types/tensorboard.py +14 -8
  162. polyaxon/_schemas/user.py +3 -3
  163. polyaxon/_schemas/version.py +2 -2
  164. polyaxon/_sdk/api/agents_v1_api.py +222 -43
  165. polyaxon/_sdk/api/artifacts_stores_v1_api.py +3 -3
  166. polyaxon/_sdk/api/auth_v1_api.py +13 -13
  167. polyaxon/_sdk/api/connections_v1_api.py +15 -15
  168. polyaxon/_sdk/api/dashboards_v1_api.py +15 -15
  169. polyaxon/_sdk/api/organizations_v1_api.py +85 -85
  170. polyaxon/_sdk/api/presets_v1_api.py +15 -15
  171. polyaxon/_sdk/api/project_dashboards_v1_api.py +29 -29
  172. polyaxon/_sdk/api/project_searches_v1_api.py +29 -29
  173. polyaxon/_sdk/api/projects_v1_api.py +284 -107
  174. polyaxon/_sdk/api/queues_v1_api.py +19 -19
  175. polyaxon/_sdk/api/runs_v1_api.py +313 -359
  176. polyaxon/_sdk/api/searches_v1_api.py +15 -15
  177. polyaxon/_sdk/api/service_accounts_v1_api.py +31 -31
  178. polyaxon/_sdk/api/tags_v1_api.py +17 -17
  179. polyaxon/_sdk/api/teams_v1_api.py +2854 -402
  180. polyaxon/_sdk/api/users_v1_api.py +254 -78
  181. polyaxon/_sdk/api/versions_v1_api.py +7 -7
  182. polyaxon/_sdk/async_client/api_client.py +4 -0
  183. polyaxon/_sdk/schemas/__init__.py +1 -1
  184. polyaxon/_sdk/schemas/v1_activity.py +8 -8
  185. polyaxon/_sdk/schemas/v1_agent.py +18 -16
  186. polyaxon/_sdk/schemas/v1_agent_state_response.py +4 -4
  187. polyaxon/_sdk/schemas/v1_agent_state_response_agent_state.py +10 -10
  188. polyaxon/_sdk/schemas/v1_agent_status_body_request.py +3 -3
  189. polyaxon/_sdk/schemas/v1_analytics_spec.py +4 -4
  190. polyaxon/_sdk/schemas/v1_artifact_tree.py +3 -3
  191. polyaxon/_sdk/schemas/v1_auth.py +1 -1
  192. polyaxon/_sdk/schemas/v1_cloning.py +3 -3
  193. polyaxon/_sdk/schemas/v1_connection_response.py +9 -9
  194. polyaxon/_sdk/schemas/v1_dashboard.py +9 -9
  195. polyaxon/_sdk/schemas/v1_dashboard_spec.py +5 -1
  196. polyaxon/_sdk/schemas/v1_entities_tags.py +2 -2
  197. polyaxon/_sdk/schemas/v1_entities_transfer.py +2 -2
  198. polyaxon/_sdk/schemas/v1_entity_notification_body.py +7 -7
  199. polyaxon/_sdk/schemas/v1_entity_stage_body_request.py +5 -5
  200. polyaxon/_sdk/schemas/v1_entity_status_body_request.py +5 -5
  201. polyaxon/_sdk/schemas/v1_events_response.py +2 -2
  202. polyaxon/_sdk/schemas/v1_list_activities_response.py +4 -4
  203. polyaxon/_sdk/schemas/v1_list_agents_response.py +4 -4
  204. polyaxon/_sdk/schemas/v1_list_bookmarks_response.py +4 -4
  205. polyaxon/_sdk/schemas/v1_list_connections_response.py +4 -4
  206. polyaxon/_sdk/schemas/v1_list_dashboards_response.py +4 -4
  207. polyaxon/_sdk/schemas/v1_list_organization_members_response.py +4 -4
  208. polyaxon/_sdk/schemas/v1_list_organizations_response.py +4 -4
  209. polyaxon/_sdk/schemas/v1_list_presets_response.py +4 -4
  210. polyaxon/_sdk/schemas/v1_list_project_versions_response.py +4 -4
  211. polyaxon/_sdk/schemas/v1_list_projects_response.py +4 -4
  212. polyaxon/_sdk/schemas/v1_list_queues_response.py +4 -4
  213. polyaxon/_sdk/schemas/v1_list_run_artifacts_response.py +4 -4
  214. polyaxon/_sdk/schemas/v1_list_run_connections_response.py +4 -4
  215. polyaxon/_sdk/schemas/v1_list_run_edges_response.py +4 -4
  216. polyaxon/_sdk/schemas/v1_list_runs_response.py +4 -4
  217. polyaxon/_sdk/schemas/v1_list_searches_response.py +4 -4
  218. polyaxon/_sdk/schemas/v1_list_service_accounts_response.py +4 -4
  219. polyaxon/_sdk/schemas/v1_list_tags_response.py +4 -4
  220. polyaxon/_sdk/schemas/v1_list_team_members_response.py +4 -4
  221. polyaxon/_sdk/schemas/v1_list_teams_response.py +4 -4
  222. polyaxon/_sdk/schemas/v1_list_token_response.py +4 -4
  223. polyaxon/_sdk/schemas/v1_operation_body.py +8 -8
  224. polyaxon/_sdk/schemas/v1_organization.py +16 -16
  225. polyaxon/_sdk/schemas/v1_organization_member.py +6 -6
  226. polyaxon/_sdk/schemas/v1_password_change.py +3 -3
  227. polyaxon/_sdk/schemas/v1_pipeline.py +3 -3
  228. polyaxon/_sdk/schemas/v1_preset.py +16 -9
  229. polyaxon/_sdk/schemas/v1_project.py +17 -17
  230. polyaxon/_sdk/schemas/v1_project_settings.py +12 -10
  231. polyaxon/_sdk/schemas/v1_project_version.py +20 -20
  232. polyaxon/_sdk/schemas/v1_queue.py +12 -12
  233. polyaxon/_sdk/schemas/v1_run.py +38 -38
  234. polyaxon/_sdk/schemas/v1_run_connection.py +3 -3
  235. polyaxon/_sdk/schemas/v1_run_edge.py +5 -5
  236. polyaxon/_sdk/schemas/v1_run_edge_lineage.py +3 -3
  237. polyaxon/_sdk/schemas/v1_run_edges_graph.py +1 -1
  238. polyaxon/_sdk/schemas/v1_run_reference_catalog.py +4 -4
  239. polyaxon/_sdk/schemas/v1_run_settings.py +9 -9
  240. polyaxon/_sdk/schemas/v1_search.py +10 -10
  241. polyaxon/_sdk/schemas/v1_search_spec.py +14 -14
  242. polyaxon/_sdk/schemas/v1_section_spec.py +12 -7
  243. polyaxon/_sdk/schemas/v1_service_account.py +9 -9
  244. polyaxon/_sdk/schemas/v1_settings_catalog.py +4 -3
  245. polyaxon/_sdk/schemas/v1_tag.py +6 -6
  246. polyaxon/_sdk/schemas/v1_team.py +11 -8
  247. polyaxon/_sdk/schemas/v1_team_member.py +6 -6
  248. polyaxon/_sdk/schemas/v1_team_settings.py +2 -2
  249. polyaxon/_sdk/schemas/v1_token.py +10 -10
  250. polyaxon/_sdk/schemas/v1_trial_start.py +6 -6
  251. polyaxon/_sdk/schemas/v1_user.py +6 -7
  252. polyaxon/_sdk/schemas/v1_user_access.py +17 -0
  253. polyaxon/_sdk/schemas/v1_user_email.py +1 -1
  254. polyaxon/_sdk/schemas/v1_user_singup.py +5 -5
  255. polyaxon/_sdk/schemas/v1_uuids.py +1 -1
  256. polyaxon/_sidecar/container/__init__.py +39 -20
  257. polyaxon/_sidecar/container/monitors/logs.py +10 -13
  258. polyaxon/_sidecar/ignore.py +0 -1
  259. polyaxon/_utils/cli_constants.py +2 -0
  260. polyaxon/_utils/fqn_utils.py +25 -2
  261. polyaxon/_utils/test_utils.py +2 -1
  262. polyaxon/pkg.py +1 -1
  263. polyaxon/schemas.py +1 -1
  264. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/METADATA +43 -43
  265. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/RECORD +269 -252
  266. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/WHEEL +1 -1
  267. polyaxon/_sdk/schemas/v1_project_user_access.py +0 -10
  268. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/LICENSE +0 -0
  269. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/entry_points.txt +0 -0
  270. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,7 @@ from datetime import datetime
4
4
  from requests import HTTPError
5
5
  from typing import Dict, List, Optional, Tuple, Union
6
6
 
7
- from clipped.utils.json import orjson_dumps
7
+ from clipped.utils.json import orjson_dumps, orjson_loads
8
8
  from clipped.utils.paths import check_or_create_path, delete_path
9
9
  from clipped.utils.query_params import get_query_params
10
10
  from clipped.utils.tz import now
@@ -12,6 +12,7 @@ from clipped.utils.validation import validate_tags
12
12
 
13
13
  from polyaxon._client.client import PolyaxonClient
14
14
  from polyaxon._client.decorators import client_handler, get_global_or_inline_config
15
+ from polyaxon._client.mixin import ClientMixin
15
16
  from polyaxon._constants.globals import DEFAULT
16
17
  from polyaxon._contexts import paths as ctx_paths
17
18
  from polyaxon._env_vars.getters.user import get_local_owner
@@ -21,13 +22,17 @@ from polyaxon._sdk.schemas.v1_list_project_versions_response import (
21
22
  )
22
23
  from polyaxon._sdk.schemas.v1_project import V1Project
23
24
  from polyaxon._sdk.schemas.v1_project_version import V1ProjectVersion
24
- from polyaxon._utils.fqn_utils import get_entity_full_name, get_entity_info
25
+ from polyaxon._utils.fqn_utils import (
26
+ get_entity_full_name,
27
+ get_entity_info,
28
+ split_owner_team_space,
29
+ )
25
30
  from polyaxon.exceptions import ApiException, PolyaxonClientException
26
31
  from polyaxon.logger import logger
27
32
  from traceml.artifacts import V1RunArtifact
28
33
 
29
34
 
30
- class ProjectClient:
35
+ class ProjectClient(ClientMixin):
31
36
  """ProjectClient is a client to communicate with Polyaxon projects endpoints.
32
37
 
33
38
  If no values are passed to this class,
@@ -94,26 +99,13 @@ class ProjectClient:
94
99
  if not owner:
95
100
  raise PolyaxonClientException("Please provide a valid owner.")
96
101
 
102
+ owner, team = split_owner_team_space(owner)
97
103
  self._client = client
98
104
  self._owner = owner or DEFAULT
105
+ self._team = team
99
106
  self._project = project
100
107
  self._project_data = V1Project.construct()
101
108
 
102
- @property
103
- def client(self):
104
- if self._client:
105
- return self._client
106
- self._client = PolyaxonClient()
107
- return self._client
108
-
109
- @property
110
- def owner(self):
111
- return self._owner
112
-
113
- @property
114
- def project(self):
115
- return self._project
116
-
117
109
  @property
118
110
  def project_data(self):
119
111
  return self._project_data
@@ -139,11 +131,19 @@ class ProjectClient:
139
131
  Returns:
140
132
  V1Project, project instance from the response.
141
133
  """
142
- self._project_data = self.client.projects_v1.create_project(
143
- self.owner,
144
- data,
145
- async_req=False,
146
- )
134
+ if self.team:
135
+ self._project_data = self.client.projects_v1.create_team_project(
136
+ self.owner,
137
+ self.team,
138
+ data,
139
+ async_req=False,
140
+ )
141
+ else:
142
+ self._project_data = self.client.projects_v1.create_project(
143
+ self.owner,
144
+ data,
145
+ async_req=False,
146
+ )
147
147
  self._project_data.owner = self.owner
148
148
  self._project = self._project_data.name
149
149
  return self._project_data
@@ -727,9 +727,12 @@ class ProjectClient:
727
727
  description: Optional[str] = None,
728
728
  tags: Optional[Union[str, List[str]]] = None,
729
729
  content: Optional[Union[str, Dict]] = None,
730
+ readme: Optional[str] = None,
730
731
  run: Optional[str] = None,
731
732
  connection: Optional[str] = None,
732
733
  artifacts: Optional[List[str]] = None,
734
+ stage: Optional[V1Stages] = None,
735
+ stage_conditions: Optional[List[V1StageCondition]] = None,
733
736
  force: bool = False,
734
737
  ) -> V1ProjectVersion:
735
738
  """Creates or Updates a project version based on the data passed.
@@ -745,9 +748,12 @@ class ProjectClient:
745
748
  description: str, optional, the version description.
746
749
  tags: str or List[str], optional.
747
750
  content: str or dict, optional, content/metadata (JSON object) of the version.
751
+ readme: str, optional, the version readme.
748
752
  run: str, optional, a uuid reference to the run.
749
753
  connection: str, optional, a uuid reference to a connection.
750
754
  artifacts: List[str], optional, list of artifacts to highlight(requires passing a run)
755
+ stage: V1Stages, optional, the version stage.
756
+ stage_conditions: List[V1StageCondition], optional, the version stage conditions.
751
757
  force: bool, optional, to force push, i.e. update if exists.
752
758
 
753
759
  Returns:
@@ -783,12 +789,18 @@ class ProjectClient:
783
789
  version_config.tags = tags
784
790
  if content:
785
791
  version_config.content = content # type: ignore
792
+ if readme is not None:
793
+ version_config.readme = readme
786
794
  if run:
787
795
  version_config.run = run
788
796
  if artifacts is not None:
789
797
  version_config.artifacts = artifacts
790
798
  if connection is not None:
791
799
  version_config.connection = connection
800
+ if stage is not None:
801
+ version_config.stage = stage
802
+ if stage_conditions is not None:
803
+ version_config.stage_conditions = stage_conditions
792
804
  return self.patch_version(
793
805
  kind=kind,
794
806
  version=version,
@@ -800,9 +812,12 @@ class ProjectClient:
800
812
  description=description,
801
813
  tags=tags,
802
814
  run=run,
815
+ readme=readme,
803
816
  artifacts=artifacts,
804
817
  connection=connection,
805
818
  content=content,
819
+ stage=stage,
820
+ stage_conditions=stage_conditions,
806
821
  )
807
822
  return self.create_version(kind=kind, data=version_config)
808
823
 
@@ -1575,3 +1590,183 @@ class ProjectClient:
1575
1590
  path=path,
1576
1591
  download_artifacts=download_artifacts,
1577
1592
  )
1593
+
1594
+ @classmethod
1595
+ @client_handler(check_no_op=True)
1596
+ def load_offline_version(
1597
+ cls,
1598
+ kind: V1ProjectVersionKind,
1599
+ version: str,
1600
+ path: str,
1601
+ project_client: Optional["ProjectClient"] = None,
1602
+ reset_project: bool = False,
1603
+ raise_if_not_found: bool = False,
1604
+ ) -> Optional["ProjectClient"]:
1605
+ """Loads a project version from a local path.
1606
+
1607
+ Args:
1608
+ kind: V1ProjectVersionKind, kind of the project version.
1609
+ version: str, required, the version name/tag.
1610
+ path: str, local path where to load the version's metadata and artifacts from.
1611
+ project_client: ProjectClient, optional,
1612
+ a project client to update with the loaded version.
1613
+ reset_project: bool, optional, to reset the project client with the loaded version.
1614
+ raise_if_not_found: bool, optional, to raise an exception if the version is not found.
1615
+
1616
+ Returns:
1617
+ ProjectClient, a project client with the loaded version.
1618
+ """
1619
+ path = ctx_paths.get_offline_path(
1620
+ entity_value=version, entity_kind=kind, path=path
1621
+ )
1622
+ version_path = "{}/{}".format(path, ctx_paths.CONTEXT_LOCAL_VERSION)
1623
+ if not os.path.exists(version_path):
1624
+ if raise_if_not_found:
1625
+ raise PolyaxonClientException(
1626
+ "Version not found in the provided path: {}".format(path)
1627
+ )
1628
+ else:
1629
+ logger.info(f"Offline data was not found: {version_path}")
1630
+ return None
1631
+
1632
+ with open(version_path, "r") as config_file:
1633
+ config_str = config_file.read()
1634
+ version_config = V1ProjectVersion(**orjson_loads(config_str))
1635
+ owner = version_config.owner
1636
+ project = version_config.project
1637
+ if project_client:
1638
+ if reset_project or not owner:
1639
+ owner = project_client.owner
1640
+ if reset_project or not project:
1641
+ project = project_client.project
1642
+ project_client._owner = owner
1643
+ project_client._project = project
1644
+ else:
1645
+ project_client = cls(
1646
+ owner=owner,
1647
+ project=project,
1648
+ )
1649
+ logger.info("Loaded version `{}`".format(version_path))
1650
+
1651
+ return project_client
1652
+
1653
+ @client_handler(check_no_op=True, check_offline=True)
1654
+ def push_version(
1655
+ self,
1656
+ kind: V1ProjectVersionKind,
1657
+ version: str,
1658
+ path: str,
1659
+ force: bool = False,
1660
+ clean: bool = False,
1661
+ ):
1662
+ """Pushes a local version from a local path to Polyaxon's API.
1663
+
1664
+ This is a generic function based on the kind passed and pushes a:
1665
+ * component version
1666
+ * model version
1667
+ * artifact version
1668
+
1669
+ Args:
1670
+ kind: V1ProjectVersionKind, kind of the project version.
1671
+ version: str, required, the version name/tag.
1672
+ path: str, optional, defaults to the offline root path,
1673
+ path where to load the metadata and artifacts from.
1674
+ force: bool, optional, to force push, i.e. update if exists.
1675
+ clean: bool, optional, to clean the version after pushing.
1676
+ """
1677
+ path = ctx_paths.get_offline_path(
1678
+ entity_value=version, entity_kind=kind, path=path
1679
+ )
1680
+ version_path = "{}/{}".format(path, ctx_paths.CONTEXT_LOCAL_VERSION)
1681
+ with open(version_path, "r") as config_file:
1682
+ config_str = config_file.read()
1683
+ version_config = V1ProjectVersion(**orjson_loads(config_str))
1684
+
1685
+ self.register_version(
1686
+ kind=kind,
1687
+ version=version,
1688
+ description=version_config.description,
1689
+ tags=version_config.tags,
1690
+ content=version_config.content,
1691
+ readme=version_config.readme,
1692
+ run=version_config.run,
1693
+ stage=version_config.stage,
1694
+ stage_conditions=version_config.stage_conditions,
1695
+ connection=version_config.connection,
1696
+ artifacts=version_config.artifacts,
1697
+ force=force,
1698
+ )
1699
+ if clean:
1700
+ delete_path(path)
1701
+
1702
+ @client_handler(check_no_op=True, check_offline=True)
1703
+ def push_component_version(
1704
+ self,
1705
+ version: str,
1706
+ path: str,
1707
+ force: bool = False,
1708
+ clean: bool = False,
1709
+ ):
1710
+ """Pushes a local component version to a remove server.
1711
+
1712
+ Args:
1713
+ version: str, required, the version name/tag.
1714
+ path: str, local path where to load the metadata and artifacts from.
1715
+ force: bool, optional, to force push, i.e. update if exists.
1716
+ clean: bool, optional, to clean the version after pushing.
1717
+ """
1718
+ return self.push_version(
1719
+ kind=V1ProjectVersionKind.COMPONENT,
1720
+ version=version,
1721
+ path=path,
1722
+ force=force,
1723
+ clean=clean,
1724
+ )
1725
+
1726
+ @client_handler(check_no_op=True, check_offline=True)
1727
+ def push_model_version(
1728
+ self,
1729
+ version: str,
1730
+ path: str,
1731
+ force: bool = True,
1732
+ clean: bool = False,
1733
+ ):
1734
+ """Pushes a local model version to a remove server.
1735
+
1736
+ Args:
1737
+ version: str, required, the version name/tag.
1738
+ path: str, local path where to load the metadata and artifacts from.
1739
+ force: bool, optional, to force push, i.e. update if exists.
1740
+ clean: bool, optional, to clean the version after pushing.
1741
+ """
1742
+ return self.pull_version(
1743
+ kind=V1ProjectVersionKind.MODEL,
1744
+ version=version,
1745
+ path=path,
1746
+ force=force,
1747
+ clean=clean,
1748
+ )
1749
+
1750
+ @client_handler(check_no_op=True, check_offline=True)
1751
+ def push_artifact_version(
1752
+ self,
1753
+ version: str,
1754
+ path: str,
1755
+ force: bool = True,
1756
+ clean: bool = False,
1757
+ ):
1758
+ """Pushes a local artifact version to a remote server.
1759
+
1760
+ Args:
1761
+ version: str, required, the version name/tag.
1762
+ path: str, local path where to load the metadata and artifacts from.
1763
+ force: bool, optional, to force push, i.e. update if exists.
1764
+ clean: bool, optional, to clean the version after pushing.
1765
+ """
1766
+ return self.pull_version(
1767
+ kind=V1ProjectVersionKind.ARTIFACT,
1768
+ version=version,
1769
+ path=path,
1770
+ force=force,
1771
+ clean=clean,
1772
+ )
polyaxon/_client/run.py CHANGED
@@ -21,6 +21,7 @@ from clipped.utils.paths import (
21
21
  get_base_filename,
22
22
  get_dirs_under_path,
23
23
  get_files_in_path_context,
24
+ set_permissions,
24
25
  )
25
26
  from clipped.utils.query_params import (
26
27
  get_logs_params,
@@ -35,6 +36,7 @@ from polyaxon import settings
35
36
  from polyaxon._cli.errors import handle_cli_error
36
37
  from polyaxon._client.client import PolyaxonClient
37
38
  from polyaxon._client.decorators import client_handler, get_global_or_inline_config
39
+ from polyaxon._client.mixin import ClientMixin
38
40
  from polyaxon._client.store import PolyaxonStore
39
41
  from polyaxon._constants.metadata import META_COPY_ARTIFACTS, META_RECOMPILE
40
42
  from polyaxon._containers.names import MAIN_CONTAINER_NAMES
@@ -63,7 +65,12 @@ from polyaxon._sdk.schemas.v1_operation_body import V1OperationBody
63
65
  from polyaxon._sdk.schemas.v1_project_version import V1ProjectVersion
64
66
  from polyaxon._sdk.schemas.v1_run import V1Run
65
67
  from polyaxon._sdk.schemas.v1_run_settings import V1RunSettings
66
- from polyaxon._utils.fqn_utils import get_entity_full_name, to_fqn_name
68
+ from polyaxon._sdk.schemas.v1_settings_catalog import V1SettingsCatalog
69
+ from polyaxon._utils.fqn_utils import (
70
+ get_entity_full_name,
71
+ split_owner_team_space,
72
+ to_fqn_name,
73
+ )
67
74
  from polyaxon._utils.urls_utils import get_proxy_run_url
68
75
  from polyaxon.api import K8S_V1_LOCATION, STREAMS_V1_LOCATION
69
76
  from polyaxon.exceptions import ApiException, PolyaxonClientException
@@ -80,7 +87,7 @@ if TYPE_CHECKING:
80
87
  from traceml.tracking.run import Run
81
88
 
82
89
 
83
- class RunClient:
90
+ class RunClient(ClientMixin):
84
91
  """RunClient is a client to communicate with Polyaxon runs endpoints.
85
92
 
86
93
  If no values are passed to this class,
@@ -146,7 +153,7 @@ class RunClient:
146
153
  return
147
154
 
148
155
  try:
149
- owner, project = get_project_or_local(
156
+ owner, _, project = get_project_or_local(
150
157
  get_entity_full_name(owner=owner, entity=project)
151
158
  )
152
159
  except PolyaxonClientException:
@@ -166,8 +173,10 @@ class RunClient:
166
173
  if error_message and not self._is_offline:
167
174
  raise PolyaxonClientException(error_message)
168
175
 
176
+ owner, team = split_owner_team_space(owner)
169
177
  self._client = client
170
178
  self._owner = owner
179
+ self._team = team
171
180
  self._project = project
172
181
  self._run_uuid = (
173
182
  get_run_or_local(run_uuid)
@@ -218,12 +227,23 @@ class RunClient:
218
227
  return client.config.no_op
219
228
  return settings.CLIENT_CONFIG.no_op
220
229
 
221
- @property
222
- def client(self):
223
- if self._client:
224
- return self._client
225
- self._client = PolyaxonClient()
226
- return self._client
230
+ def _reset_agent(self, agent: Optional[str] = None):
231
+ if agent:
232
+ agent = self.client.agents_v1.get_agent(self.owner, agent)
233
+ self.settings.agent = V1SettingsCatalog(
234
+ uuid=agent.uuid,
235
+ name=agent.name,
236
+ version=agent.version,
237
+ url=agent.hostname,
238
+ )
239
+ self.settings.namespace = agent.namespace
240
+ self.settings.artifacts_store = None
241
+
242
+ def _use_agent_host(self):
243
+ if self.settings.agent and self.settings.agent.url:
244
+ self.reset_client(
245
+ host=self.settings.agent.url, POLYAXON_HOST=self.settings.agent.url
246
+ )
227
247
 
228
248
  @property
229
249
  def store(self):
@@ -256,20 +276,6 @@ class RunClient:
256
276
  return self.settings.artifacts_store.name
257
277
  return None
258
278
 
259
- @property
260
- def owner(self) -> str:
261
- return self._owner or ""
262
-
263
- def set_owner(self, owner: str):
264
- self._owner = owner
265
-
266
- @property
267
- def project(self) -> str:
268
- return self._project or ""
269
-
270
- def set_project(self, project: str):
271
- self._project = project
272
-
273
279
  @property
274
280
  def run_uuid(self) -> str:
275
281
  return self._run_uuid
@@ -898,6 +904,7 @@ class RunClient:
898
904
  """
899
905
  if not self.settings:
900
906
  self.refresh_data()
907
+ self._use_agent_host()
901
908
  params = get_logs_params(
902
909
  last_file=last_file, last_time=last_time, connection=self.artifacts_store
903
910
  )
@@ -921,6 +928,7 @@ class RunClient:
921
928
  def inspect(self):
922
929
  if not self.settings:
923
930
  self.refresh_data()
931
+ self._use_agent_host()
924
932
  params = get_streams_params(connection=self.artifacts_store, status=self.status)
925
933
  return self.client.runs_v1.inspect_run(
926
934
  self.namespace, self.owner, self.project, self.run_uuid, **params
@@ -994,6 +1002,10 @@ class RunClient:
994
1002
  if not container:
995
1003
  container = pod_containers[0]
996
1004
 
1005
+ if not self.settings:
1006
+ self.refresh_data()
1007
+ self._use_agent_host()
1008
+
997
1009
  url = get_proxy_run_url(
998
1010
  service=K8S_V1_LOCATION,
999
1011
  namespace=self.namespace,
@@ -1039,6 +1051,8 @@ class RunClient:
1039
1051
  """
1040
1052
  if not self.settings:
1041
1053
  self.refresh_data()
1054
+ self._use_agent_host()
1055
+
1042
1056
  params = get_streams_params(self.artifacts_store)
1043
1057
  return self.client.runs_v1.get_run_events(
1044
1058
  self.namespace,
@@ -1074,6 +1088,8 @@ class RunClient:
1074
1088
  """
1075
1089
  if not self.settings:
1076
1090
  self.refresh_data()
1091
+ self._use_agent_host()
1092
+
1077
1093
  params = get_streams_params(self.artifacts_store)
1078
1094
  return self.client.runs_v1.get_multi_run_events(
1079
1095
  self.namespace,
@@ -1310,6 +1326,7 @@ class RunClient:
1310
1326
  """
1311
1327
  if not self.settings:
1312
1328
  self.refresh_data()
1329
+ self._use_agent_host()
1313
1330
  params = get_streams_params(self.artifacts_store)
1314
1331
  return self.client.runs_v1.get_run_artifact(
1315
1332
  namespace=self.namespace,
@@ -1343,6 +1360,10 @@ class RunClient:
1343
1360
  if not self.run_uuid:
1344
1361
  return
1345
1362
 
1363
+ if not self.settings:
1364
+ self.refresh_data()
1365
+ self._use_agent_host()
1366
+
1346
1367
  lineage_path = lineage.path or ""
1347
1368
  summary = lineage.summary or {}
1348
1369
  is_event = summary.get("is_event")
@@ -1421,6 +1442,8 @@ class RunClient:
1421
1442
  """
1422
1443
  if not self.settings:
1423
1444
  self.refresh_data()
1445
+ self._use_agent_host()
1446
+
1424
1447
  url = get_proxy_run_url(
1425
1448
  service=STREAMS_V1_LOCATION,
1426
1449
  namespace=self.namespace,
@@ -1460,6 +1483,8 @@ class RunClient:
1460
1483
  """
1461
1484
  if not self.settings:
1462
1485
  self.refresh_data()
1486
+ self._use_agent_host()
1487
+
1463
1488
  url = get_proxy_run_url(
1464
1489
  service=STREAMS_V1_LOCATION,
1465
1490
  namespace=self.namespace,
@@ -1491,6 +1516,7 @@ class RunClient:
1491
1516
  untar: bool = False,
1492
1517
  overwrite: bool = True,
1493
1518
  show_progress: bool = True,
1519
+ agent: Optional[str] = None,
1494
1520
  ):
1495
1521
  """Uploads a single artifact to the run's artifacts store path.
1496
1522
 
@@ -1501,12 +1527,17 @@ class RunClient:
1501
1527
  it should be decompressed on the artifacts store.
1502
1528
  overwrite: bool, optional, if the file uploaded should overwrite any previous content.
1503
1529
  show_progress: bool, to show a progress bar.
1530
+ agent: str, optional, uuid reference of an agent to use.
1504
1531
 
1505
1532
  Returns:
1506
1533
  str
1507
1534
  """
1508
1535
  if not self.settings:
1509
1536
  self.refresh_data()
1537
+ if agent:
1538
+ self._reset_agent(agent)
1539
+
1540
+ self._use_agent_host()
1510
1541
 
1511
1542
  params = get_streams_params(connection=self.artifacts_store)
1512
1543
  url = get_proxy_run_url(
@@ -1536,6 +1567,7 @@ class RunClient:
1536
1567
  path: str = "",
1537
1568
  overwrite: bool = True,
1538
1569
  relative_to: Optional[str] = None,
1570
+ agent: Optional[str] = None,
1539
1571
  ):
1540
1572
  """Uploads a full directory to the run's artifacts store path.
1541
1573
 
@@ -1548,7 +1580,7 @@ class RunClient:
1548
1580
  overwrite: bool, optional, if the file uploaded should overwrite any previous content.
1549
1581
  relative_to: str, optional, if the path uploaded is not the current dir,
1550
1582
  and you want to cancel the relative path.
1551
-
1583
+ agent: str, optional, uuid reference of an agent to use.
1552
1584
  Returns:
1553
1585
  str.
1554
1586
  """
@@ -1568,6 +1600,7 @@ class RunClient:
1568
1600
  path=path or "",
1569
1601
  overwrite=overwrite,
1570
1602
  relative_to=relative_to,
1603
+ agent=agent,
1571
1604
  )
1572
1605
 
1573
1606
  @client_handler(check_no_op=True, check_offline=True)
@@ -1577,6 +1610,7 @@ class RunClient:
1577
1610
  path: str = "",
1578
1611
  overwrite: bool = True,
1579
1612
  relative_to: Optional[str] = None,
1613
+ agent: Optional[str] = None,
1580
1614
  ):
1581
1615
  """Uploads multiple artifacts to the run's artifacts store path.
1582
1616
 
@@ -1586,7 +1620,7 @@ class RunClient:
1586
1620
  overwrite: bool, optional, if the file uploaded should overwrite any previous content.
1587
1621
  relative_to: str, optional, if the path uploaded is not the current dir,
1588
1622
  and you want to cancel the relative path.
1589
-
1623
+ agent: str, optional, uuid reference of an agent to use.
1590
1624
  Returns:
1591
1625
  str.
1592
1626
  """
@@ -1596,6 +1630,10 @@ class RunClient:
1596
1630
 
1597
1631
  if not self.settings:
1598
1632
  self.refresh_data()
1633
+ if agent:
1634
+ self._reset_agent(agent)
1635
+
1636
+ self._use_agent_host()
1599
1637
 
1600
1638
  params = get_streams_params(connection=self.artifacts_store)
1601
1639
  url = get_proxy_run_url(
@@ -1626,6 +1664,8 @@ class RunClient:
1626
1664
  """
1627
1665
  if not self.settings:
1628
1666
  self.refresh_data()
1667
+ self._use_agent_host()
1668
+
1629
1669
  params = get_streams_params(connection=self.artifacts_store)
1630
1670
  self.client.runs_v1.delete_run_artifact(
1631
1671
  namespace=self.namespace,
@@ -1645,6 +1685,8 @@ class RunClient:
1645
1685
  """
1646
1686
  if not self.settings:
1647
1687
  self.refresh_data()
1688
+ self._use_agent_host()
1689
+
1648
1690
  params = get_streams_params(connection=self.artifacts_store)
1649
1691
  return self.client.runs_v1.delete_run_artifacts(
1650
1692
  namespace=self.namespace,
@@ -1667,6 +1709,8 @@ class RunClient:
1667
1709
  """
1668
1710
  if not self.settings:
1669
1711
  self.refresh_data()
1712
+ self._use_agent_host()
1713
+
1670
1714
  params = get_streams_params(connection=self.artifacts_store)
1671
1715
  return self.client.runs_v1.get_run_artifacts_tree(
1672
1716
  namespace=self.namespace,
@@ -2117,9 +2161,9 @@ class RunClient:
2117
2161
  abspath = filepath if is_abs() else os.path.abspath(filepath)
2118
2162
 
2119
2163
  for_patterns = []
2120
- if getattr(self, "_artifacts_path"):
2164
+ if getattr(self, "_artifacts_path", None):
2121
2165
  for_patterns.append(getattr(self, "_artifacts_path"))
2122
- if getattr(self, "_store_path"):
2166
+ if getattr(self, "_store_path", None):
2123
2167
  for_patterns.append(getattr(self, "_store_path"))
2124
2168
  context_root = (
2125
2169
  ctx_paths.CONTEXT_OFFLINE_ROOT
@@ -2853,6 +2897,7 @@ class RunClient:
2853
2897
  config_file.write(
2854
2898
  orjson_dumps(self.client.sanitize_for_serialization(self.run_data))
2855
2899
  )
2900
+ set_permissions(run_path)
2856
2901
 
2857
2902
  if not self._artifacts_lineage:
2858
2903
  logger.debug("Persist offline run call did not find any lineage data. ")
@@ -2868,6 +2913,7 @@ class RunClient:
2868
2913
  ]
2869
2914
  )
2870
2915
  )
2916
+ set_permissions(lineages_path)
2871
2917
 
2872
2918
  @classmethod
2873
2919
  @client_handler(check_no_op=True)
@@ -2876,6 +2922,8 @@ class RunClient:
2876
2922
  path: str,
2877
2923
  run_client: Optional[Union["RunClient", "Run"]] = None,
2878
2924
  reset_project: bool = False,
2925
+ reset_uuid: bool = False,
2926
+ name: Optional[str] = None,
2879
2927
  raise_if_not_found: bool = False,
2880
2928
  ) -> Optional[Union["RunClient", "Run"]]:
2881
2929
  """Loads an offline run from a local path.
@@ -2892,6 +2940,8 @@ class RunClient:
2892
2940
  from the local run.
2893
2941
  raise_if_not_found: bool, optional, a flag to raise an error if the local path does not
2894
2942
  contain a persisted run.
2943
+ reset_uuid: bool, optional, a flag to reset the run's uuid.
2944
+ name: str, optional, a name to set for the run.
2895
2945
  """
2896
2946
  run_path = "{}/{}".format(path, ctx_paths.CONTEXT_LOCAL_RUN)
2897
2947
  if not os.path.isfile(run_path):
@@ -2906,6 +2956,10 @@ class RunClient:
2906
2956
  run_config = V1Run(**orjson_loads(config_str))
2907
2957
  owner = run_config.owner
2908
2958
  project = run_config.project
2959
+ if reset_uuid:
2960
+ run_config.uuid = uuid.uuid4().hex
2961
+ if name:
2962
+ run_config.name = name
2909
2963
  if run_client:
2910
2964
  if reset_project or not owner:
2911
2965
  owner = run_client.owner
@@ -2964,6 +3018,7 @@ class RunClient:
2964
3018
  path: str,
2965
3019
  upload_artifacts: bool = True,
2966
3020
  clean: bool = False,
3021
+ agent: Optional[str] = None,
2967
3022
  ):
2968
3023
  """Syncs an offline run to Polyaxon's API and artifacts store.
2969
3024
 
@@ -2972,6 +3027,7 @@ class RunClient:
2972
3027
  path: str, root path where the run's metadata & artifacts are stored.
2973
3028
  upload_artifacts: bool, optional, flag to trigger artifacts upload.
2974
3029
  clean: bool, optional, flag to clean local path after pushing the run.
3030
+ agent: str, optional, uuid reference of an agent to use.
2975
3031
  """
2976
3032
  # We ensure that the is_offline is False
2977
3033
  is_offline = self._is_offline
@@ -3004,6 +3060,7 @@ class RunClient:
3004
3060
  path="/",
3005
3061
  overwrite=True,
3006
3062
  relative_to=path,
3063
+ agent=agent,
3007
3064
  )
3008
3065
  logger.info(f"Offline artifacts for run {self.run_data.uuid} uploaded")
3009
3066