Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly deprecate more stuff #490

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions encord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import requests

import encord.exceptions
from encord.common.deprecated import deprecated
from encord.configs import ENCORD_DOMAIN, ApiKeyConfig, Config, EncordConfig, SshConfig
from encord.constants.enums import DataType
from encord.constants.model import AutomationModels, Device
Expand Down Expand Up @@ -142,7 +143,7 @@
)
from encord.project_ontology.classification_type import ClassificationType
from encord.project_ontology.object_type import ObjectShape
from encord.project_ontology.ontology import Ontology
from encord.project_ontology.ontology import Ontology as LegacyOntology
from encord.utilities.client_utilities import optional_datetime_to_iso_str, optional_set_to_list
from encord.utilities.project_user import ProjectUser, ProjectUserRole

Expand Down Expand Up @@ -958,22 +959,24 @@ def remove_datasets(self, dataset_hashes: List[str]) -> bool:
"""
return self._querier.basic_delete(ProjectDataset, uid=dataset_hashes)

def get_project_ontology(self) -> Ontology:
def get_project_ontology(self) -> LegacyOntology:
project = self.get_project()
ontology = project["editor_ontology"]
return Ontology.from_dict(ontology)
return LegacyOntology.from_dict(ontology)

@deprecated("0.1.102", alternative="encord.ontology.Ontology class")
def add_object(self, name: str, shape: ObjectShape) -> bool:
"""
This function is documented in :meth:`encord.project.Project.add_object`.
"""
if len(name) == 0:
if not name:
raise ValueError("Ontology object name is empty")

ontology = self.get_project_ontology()
ontology.add_object(name, shape)
return self.__set_project_ontology(ontology)

@deprecated("0.1.102", alternative="encord.ontology.Ontology class")
def add_classification(
self,
name: str,
Expand All @@ -984,7 +987,7 @@ def add_classification(
"""
This function is documented in :meth:`encord.project.Project.add_classification`.
"""
if len(name) == 0:
if not name:
raise ValueError("Ontology classification name is empty")

ontology = self.get_project_ontology()
Expand Down Expand Up @@ -1305,7 +1308,7 @@ def get_label_logs(

return self._querier.get_multiple(LabelLog, payload=payload.to_dict(by_alias=False))

def __set_project_ontology(self, ontology: Ontology) -> bool:
def __set_project_ontology(self, ontology: LegacyOntology) -> bool:
"""
Save updated project ontology
Args:
Expand Down
4 changes: 2 additions & 2 deletions encord/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def get_project_ontology(self) -> LegacyOntology:
"""
return self._client.get_project_ontology()

@deprecated("0.1.102", alternative="Ontology class")
@deprecated("0.1.102", alternative="encord.ontology.Ontology class")
def add_object(self, name: str, shape: ObjectShape) -> bool:
"""
DEPRECATED: prefer using :class:`Ontology <encord.ontology.Ontology>` to manipulate ontology.
Expand All @@ -363,7 +363,7 @@ def add_object(self, name: str, shape: ObjectShape) -> bool:
self.refetch_data()
return res

@deprecated("0.1.102", alternative="Ontology class")
@deprecated("0.1.102", alternative="encord.ontology.Ontology class")
def add_classification(
self,
name: str,
Expand Down