Skip to content

Commit 77b3fc9

Browse files
authored
Merge pull request #680 from splitgraph/add-image-to-schema-method-cu-2g9ggh0
Image schema repr method
2 parents f42474d + 7016893 commit 77b3fc9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

splitgraph/core/image.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def __eq__(self, other: object) -> bool:
7070
return NotImplemented
7171
return self.image_hash == other.image_hash and self.repository == other.repository
7272

73+
def to_schema(self) -> str:
74+
"""Schema reference for the given image."""
75+
return self.repository.to_schema() + ":" + self.image_hash
76+
7377
def get_parent_children(self) -> Tuple[Optional[str], List[str]]:
7478
"""Gets the parent and a list of children of a given image."""
7579
parent = self.parent_id
@@ -117,8 +121,7 @@ def get_table(self, table_name: str) -> Table:
117121
)
118122
if not result:
119123
raise TableNotFoundError(
120-
"Image %s:%s does not have a table %s!"
121-
% (self.repository, self.image_hash, table_name)
124+
"Image %s does not have a table %s!" % (self.to_schema(), table_name)
122125
)
123126
table_schema, objects = result
124127
return Table(
@@ -212,9 +215,8 @@ def lq_checkout(
212215
continue
213216

214217
logging.debug(
215-
"Mounting %s:%s/%s into %s",
216-
self.repository.to_schema(),
217-
self.image_hash,
218+
"Mounting %s/%s into %s",
219+
self.to_schema(),
218220
table_name,
219221
target_schema,
220222
)

0 commit comments

Comments
 (0)