Skip to content

Commit

Permalink
[Projects] Make params and description accessible (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Jan 18, 2021
1 parent 80236b8 commit 18d69ca
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
44 changes: 44 additions & 0 deletions mlrun/projects/project.py
Expand Up @@ -592,6 +592,50 @@ def mountdir(self, mountdir):
)
self.spec.mountdir = mountdir

@property
def params(self) -> str:
"""This is a property of the spec, look there for documentation
leaving here for backwards compatibility with users code that used MlrunProjectLegacy"""
warnings.warn(
"This is a property of the spec, use project.spec.params instead"
"This will be deprecated in 0.7.0, and will be removed in 0.9.0",
# TODO: In 0.7.0 do changes in examples & demos In 0.9.0 remove
PendingDeprecationWarning,
)
return self.spec.params

@params.setter
def params(self, params):
warnings.warn(
"This is a property of the spec, use project.spec.params instead"
"This will be deprecated in 0.7.0, and will be removed in 0.9.0",
# TODO: In 0.7.0 do changes in examples & demos In 0.9.0 remove
PendingDeprecationWarning,
)
self.spec.params = params

@property
def description(self) -> str:
"""This is a property of the spec, look there for documentation
leaving here for backwards compatibility with users code that used MlrunProjectLegacy"""
warnings.warn(
"This is a property of the spec, use project.spec.description instead"
"This will be deprecated in 0.7.0, and will be removed in 0.9.0",
# TODO: In 0.7.0 do changes in examples & demos In 0.9.0 remove
PendingDeprecationWarning,
)
return self.spec.description

@description.setter
def description(self, description):
warnings.warn(
"This is a property of the spec, use project.spec.description instead"
"This will be deprecated in 0.7.0, and will be removed in 0.9.0",
# TODO: In 0.7.0 do changes in examples & demos In 0.9.0 remove
PendingDeprecationWarning,
)
self.spec.description = description

@property
def functions(self) -> list:
"""This is a property of the spec, look there for documentation
Expand Down
4 changes: 4 additions & 0 deletions tests/projects/test_project.py
Expand Up @@ -71,8 +71,12 @@ def test_create_project_from_file_with_legacy_structure():
assert project.kind == "project"
assert project.metadata.name == project_name
assert project.spec.description == description
# assert accessible from the project as well
assert project.description == description
assert project.spec.artifact_path == artifact_path
assert deepdiff.DeepDiff(params, project.spec.params, ignore_order=True,) == {}
# assert accessible from the project as well
assert deepdiff.DeepDiff(params, project.params, ignore_order=True,) == {}
assert (
deepdiff.DeepDiff(
legacy_project.functions, project.functions, ignore_order=True,
Expand Down

0 comments on commit 18d69ca

Please sign in to comment.