Skip to content

Commit 78b49ac

Browse files
committed
Fix depreaction: construct() → model_construct() (PydanticDeprecatedSince20)
1 parent 28e9646 commit 78b49ac

18 files changed

Lines changed: 59 additions & 57 deletions

File tree

cli/polyaxon/_auxiliaries/default_scheduling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_service_environment(
4545
) -> "V1Environment":
4646
from polyaxon._flow import V1Environment
4747

48-
env = V1Environment.construct()
48+
env = V1Environment.model_construct()
4949
if service and service.node_selector:
5050
env.node_selector = service.node_selector
5151
elif default_scheduling and default_scheduling.node_selector:

cli/polyaxon/_client/impersonate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def impersonate(
2424
response = client.runs_v1.impersonate_token(owner, project, run_uuid)
2525
polyaxon_client = PolyaxonClient(token=response.token)
2626
user = polyaxon_client.users_v1.get_user()
27-
access_token = AccessTokenConfig.construct(
27+
access_token = AccessTokenConfig.model_construct(
2828
username=user.username, token=response.token
2929
)
3030
create_context_auth(access_token)

cli/polyaxon/_client/organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(
116116
self._client = client
117117
self._owner = owner or DEFAULT
118118
self._team = team
119-
self._organization_data = V1Organization.construct()
119+
self._organization_data = V1Organization.model_construct()
120120

121121
@property
122122
def organization_data(self):

cli/polyaxon/_client/project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __init__(
119119
self._owner = owner or DEFAULT
120120
self._team = team
121121
self._project = project
122-
self._project_data = V1Project.construct()
122+
self._project_data = V1Project.model_construct()
123123

124124
@property
125125
def project_data(self):
@@ -950,7 +950,7 @@ def _get_content() -> str:
950950
artifacts = validate_tags(artifacts, validate_yaml=True)
951951

952952
if to_update:
953-
version_config = V1ProjectVersion.construct()
953+
version_config = V1ProjectVersion.model_construct()
954954
if description is not None:
955955
version_config.description = description
956956
if tags:
@@ -975,7 +975,7 @@ def _get_content() -> str:
975975
data=version_config,
976976
)
977977
else:
978-
version_config = V1ProjectVersion.construct(
978+
version_config = V1ProjectVersion.model_construct(
979979
name=version,
980980
description=description,
981981
tags=tags,
@@ -1199,7 +1199,7 @@ def stage_version(
11991199
"""
12001200
self._validate_kind(kind)
12011201
current_date = now()
1202-
stage_condition = V1StageCondition.construct(
1202+
stage_condition = V1StageCondition.model_construct(
12031203
type=stage,
12041204
status=True,
12051205
reason=reason or "ClientStageUpdate",

cli/polyaxon/_client/run.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(
188188
if self._is_offline or not settings.CLIENT_CONFIG.is_managed
189189
else None
190190
)
191-
self._run_data = V1Run.construct(
191+
self._run_data = V1Run.model_construct(
192192
owner=self._owner,
193193
project=self._project,
194194
uuid=self._run_uuid,
@@ -483,7 +483,7 @@ def create(
483483
content = V1Operation.from_dict(content)
484484
if isinstance(content, V1Operation):
485485
content = content.to_json()
486-
data = V1OperationBody.construct(
486+
data = V1OperationBody.model_construct(
487487
name=name,
488488
description=description,
489489
tags=tags,
@@ -765,7 +765,7 @@ def log_status(
765765
reason = reason or "PolyaxonClient"
766766
self._run_data.status = status # type: ignore
767767
current_date = now()
768-
status_condition = V1StatusCondition.construct(
768+
status_condition = V1StatusCondition.model_construct(
769769
type=status,
770770
status=True,
771771
reason=reason,
@@ -1805,7 +1805,7 @@ def restart(
18051805
content = V1Operation.from_dict(content)
18061806
if isinstance(content, V1Operation):
18071807
content = content.to_json()
1808-
body = V1Run.construct(content=content)
1808+
body = V1Run.model_construct(content=content)
18091809
if name:
18101810
body.name = name
18111811
if description:
@@ -1816,7 +1816,7 @@ def restart(
18161816
if copy_dirs or copy_files:
18171817
copy_dirs = to_list(copy_dirs, check_none=True)
18181818
copy_files = to_list(copy_files, check_none=True)
1819-
copy_artifacts = V1ArtifactsType.construct()
1819+
copy_artifacts = V1ArtifactsType.model_construct()
18201820
if copy_dirs:
18211821
copy_artifacts.dirs = [
18221822
"{}/{}".format(self.run_uuid, cp) for cp in copy_dirs
@@ -2257,7 +2257,7 @@ def log_code_ref(self, code_ref: Optional[Dict] = None, is_input: bool = True):
22572257
"""
22582258
code_ref = code_ref or get_code_reference()
22592259
if code_ref and "commit" in code_ref:
2260-
artifact_run = V1RunArtifact.construct(
2260+
artifact_run = V1RunArtifact.model_construct(
22612261
name=code_ref.get("commit"),
22622262
kind=V1ArtifactKind.CODEREF,
22632263
summary=code_ref,
@@ -2411,7 +2411,7 @@ def log_artifact_ref(
24112411
name = name or get_base_filename(path)
24122412
rel_path = self._sanitize_filepath(filepath=path, rel_path=rel_path)
24132413
if name:
2414-
artifact_run = V1RunArtifact.construct(
2414+
artifact_run = V1RunArtifact.model_construct(
24152415
name=self._sanitize_filename(name),
24162416
kind=kind,
24172417
path=rel_path,
@@ -2821,7 +2821,7 @@ def _collect_events_summaries(
28212821
# Get only the relpath from run uuid
28222822
event_rel_path = self._sanitize_filepath(filepath=f)
28232823
summary = event.get_summary()
2824-
run_artifact = V1RunArtifact.construct(
2824+
run_artifact = V1RunArtifact.model_construct(
28252825
name=event_name,
28262826
kind=V1ArtifactKind.SYSTEM if is_system_resource else events_kind,
28272827
connection=connection_name,

cli/polyaxon/_compiler/resolver/resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def resolve_hooks(
7070
if run:
7171
# Add outputs to compiled operation
7272
compiled_operation.outputs = [
73-
V1IO.construct(name=k, type=None, value=v, is_optional=True)
73+
V1IO.model_construct(name=k, type=None, value=v, is_optional=True)
7474
for k, v in (run.outputs or {}).items()
7575
]
7676
return resolver_cls(

cli/polyaxon/_compiler/resolver/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def resolve_access(self):
178178
pass
179179

180180
def resolve_agent_environment(self):
181-
agent_env = AgentResolver.construct()
181+
agent_env = AgentResolver.model_construct()
182182
agent_env.resolve(
183183
compiled_operation=self.compiled_operation, agent_config=self.agent_config
184184
)

cli/polyaxon/_flow/operations/compiled_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def set_contexts() -> List[V1IO]:
8787
for p in context_params:
8888
current_param = param_specs[p].param
8989
contexts.append(
90-
V1IO.construct(
90+
V1IO.model_construct(
9191
name=p,
9292
value=current_param.value,
9393
is_optional=True,

cli/polyaxon/_flow/operations/operation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def from_hook(cls, hook: V1Hook, contexts: Dict):
678678
content["queue"] = hook.queue
679679
if hook.namespace:
680680
content["namespace"] = hook.namespace
681-
return cls.construct(**content)
681+
return cls.model_construct(**content)
682682

683683
@classmethod
684684
def from_build(cls, build: V1Build, contexts: Optional[Dict] = None):
@@ -710,7 +710,7 @@ def from_build(cls, build: V1Build, contexts: Optional[Dict] = None):
710710
if build.cache:
711711
content["cache"] = build.cache
712712

713-
return cls.construct(**content)
713+
return cls.model_construct(**content)
714714

715715

716716
PartialV1Operation = to_partial(V1Operation)

cli/polyaxon/_flow/run/dag.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,15 @@ def process_components(self, inputs=None, ignore_hub_validation: bool = False):
444444
for g_context in ctx_sections.GLOBALS_CONTEXTS:
445445
self._context[
446446
"dag.{}.{}".format(ctx_sections.GLOBALS, g_context)
447-
] = V1IO.construct(name=g_context, type="str", value="", is_optional=True) # fmt: skip
447+
] = V1IO.model_construct(name=g_context, type="str", value="", is_optional=True) # fmt: skip
448448

449-
self._context["dag.{}".format(ctx_sections.INPUTS)] = V1IO.construct(
449+
self._context["dag.{}".format(ctx_sections.INPUTS)] = V1IO.model_construct(
450450
name="inputs", type="dict", value={}, is_optional=True
451451
)
452-
self._context["dag.{}".format(ctx_sections.GLOBALS)] = V1IO.construct(
452+
self._context["dag.{}".format(ctx_sections.GLOBALS)] = V1IO.model_construct(
453453
name="globals", type="str", value="", is_optional=True
454454
)
455-
self._context["dag.{}".format(ctx_sections.ARTIFACTS)] = V1IO.construct(
455+
self._context["dag.{}".format(ctx_sections.ARTIFACTS)] = V1IO.model_construct(
456456
name="artifacts", type="str", value="", is_optional=True
457457
)
458458

@@ -534,26 +534,26 @@ def process_components(self, inputs=None, ignore_hub_validation: bool = False):
534534
for g_context in ctx_sections.GLOBALS_CONTEXTS:
535535
self._context[
536536
"ops.{}.{}.{}".format(op_name, ctx_sections.GLOBALS, g_context)
537-
] = V1IO.construct(
537+
] = V1IO.model_construct(
538538
name=g_context, type="str", value="", is_optional=True
539539
)
540540

541541
# We allow to resolve name, status, project, all outputs/inputs, iteration
542542
self._context[
543543
"ops.{}.{}".format(op_name, ctx_sections.INPUTS)
544-
] = V1IO.construct(name="inputs", type="dict", value={}, is_optional=True) # fmt: skip
544+
] = V1IO.model_construct(name="inputs", type="dict", value={}, is_optional=True) # fmt: skip
545545
self._context[
546546
"ops.{}.{}".format(op_name, ctx_sections.OUTPUTS)
547-
] = V1IO.construct(name="outputs", type="dict", value={}, is_optional=True) # fmt: skip
547+
] = V1IO.model_construct(name="outputs", type="dict", value={}, is_optional=True) # fmt: skip
548548
self._context[
549549
"ops.{}.{}".format(op_name, ctx_sections.GLOBALS)
550-
] = V1IO.construct(name="globals", type="str", value="", is_optional=True) # fmt: skip
550+
] = V1IO.model_construct(name="globals", type="str", value="", is_optional=True) # fmt: skip
551551
self._context[
552552
"ops.{}.{}".format(op_name, ctx_sections.ARTIFACTS)
553-
] = V1IO.construct(name="artifacts", type="str", value="", is_optional=True) # fmt: skip
553+
] = V1IO.model_construct(name="artifacts", type="str", value="", is_optional=True) # fmt: skip
554554
self._context[
555555
"ops.{}.{}".format(op_name, ctx_sections.INPUTS_OUTPUTS)
556-
] = V1IO.construct(name="io", type="str", value={}, is_optional=True) # fmt: skip
556+
] = V1IO.model_construct(name="io", type="str", value={}, is_optional=True) # fmt: skip
557557

558558
for op in self.operations:
559559
if op.has_component_reference:

0 commit comments

Comments
 (0)