Tracks project level metadata Attributes: project_name: The registry-scoped unique name of the project. project_uuid: The UUID for this project
| 22 | |
| 23 | @typechecked |
| 24 | class ProjectMetadata: |
| 25 | """ |
| 26 | Tracks project level metadata |
| 27 | |
| 28 | Attributes: |
| 29 | project_name: The registry-scoped unique name of the project. |
| 30 | project_uuid: The UUID for this project |
| 31 | """ |
| 32 | |
| 33 | project_name: str |
| 34 | project_uuid: str |
| 35 | |
| 36 | def __init__( |
| 37 | self, |
| 38 | *args, |
| 39 | project_name: Optional[str] = None, |
| 40 | project_uuid: Optional[str] = None, |
| 41 | ): |
| 42 | """ |
| 43 | Creates an Project metadata object. |
| 44 | |
| 45 | Args: |
| 46 | project_name: The registry-scoped unique name of the project. |
| 47 | project_uuid: The UUID for this project |
| 48 | |
| 49 | Raises: |
| 50 | ValueError: Parameters are specified incorrectly. |
| 51 | """ |
| 52 | if not project_name: |
| 53 | raise ValueError("Project name needs to be specified") |
| 54 | |
| 55 | self.project_name = project_name |
| 56 | self.project_uuid = project_uuid or f"{uuid.uuid4()}" |
| 57 | |
| 58 | def __hash__(self) -> int: |
| 59 | return hash((self.project_name, self.project_uuid)) |
| 60 | |
| 61 | def __eq__(self, other): |
| 62 | if not isinstance(other, ProjectMetadata): |
| 63 | raise TypeError( |
| 64 | "Comparisons should only involve ProjectMetadata class objects." |
| 65 | ) |
| 66 | |
| 67 | if ( |
| 68 | self.project_name != other.project_name |
| 69 | or self.project_uuid != other.project_uuid |
| 70 | ): |
| 71 | return False |
| 72 | |
| 73 | return True |
| 74 | |
| 75 | def __str__(self): |
| 76 | return str(MessageToJson(self.to_proto())) |
| 77 | |
| 78 | def __lt__(self, other): |
| 79 | return self.project_name < other.project_name |
| 80 | |
| 81 | @classmethod |
no outgoing calls
no test coverage detected