Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/postgresql/storage.py
Show First 20 Lines • Show All 1,435 Lines • ▼ Show 20 Lines | |||||
) -> List[RawExtrinsicMetadata]: | ) -> List[RawExtrinsicMetadata]: | ||||
return [ | return [ | ||||
converters.db_to_raw_extrinsic_metadata( | converters.db_to_raw_extrinsic_metadata( | ||||
dict(zip(db.raw_extrinsic_metadata_get_cols, row)) | dict(zip(db.raw_extrinsic_metadata_get_cols, row)) | ||||
) | ) | ||||
for row in db.raw_extrinsic_metadata_get_by_ids(ids) | for row in db.raw_extrinsic_metadata_get_by_ids(ids) | ||||
] | ] | ||||
@db_transaction() | |||||
def raw_extrinsic_metadata_get_authorities( | |||||
self, target: ExtendedSWHID, db=None, cur=None, | |||||
) -> List[MetadataAuthority]: | |||||
return [ | |||||
MetadataAuthority( | |||||
type=MetadataAuthorityType(authority_type), url=authority_url | |||||
) | |||||
for ( | |||||
authority_type, | |||||
authority_url, | |||||
) in db.raw_extrinsic_metadata_get_authorities(str(target), cur) | |||||
anlambert: That call to `str(target)` looks suspicious. I think it should rather be `in db. | |||||
vlorentzAuthorUnsubmitted Done Inline Actionsraw_extrinsic_metadata_* endpoints work on SWHIDs, not sha1_gits, so it's fine. (Yes it's inconsistent with other methods of swh-storage, but it's easier to deal with multiple object types this way, and it keeps the table "standalone" if we want to break it out of swh-storage one day) vlorentz: `raw_extrinsic_metadata_*` endpoints work on SWHIDs, not `sha1_git`s, so it's fine.
(Yes it's… | |||||
anlambertUnsubmitted Not Done Inline ActionsAck, why mypy did not yell here ? Sha1Git is an alias to bytes no ? anlambert: Ack, why mypy did not yell here ? `Sha1Git` is an alias to `bytes` no ? | |||||
vlorentzAuthorUnsubmitted Done Inline ActionsAbout what? There are no Sha1Git or bytes here, just str and ExtendedSWHID vlorentz: About what? There are no `Sha1Git` or `bytes` here, just `str` and `ExtendedSWHID` | |||||
anlambertUnsubmitted Not Done Inline ActionsIn db.py, the signature is the following: def raw_extrinsic_metadata_get_authorities(self, id: Sha1Git, cur=None):, so my initial doubt. anlambert: In `db.py`, the signature is the following: `def raw_extrinsic_metadata_get_authorities(self… | |||||
vlorentzAuthorUnsubmitted Done Inline Actionsoh that's definitely a mistake. mypy doesn't see it because the db parameter has no type annotation vlorentz: oh that's definitely a mistake. mypy doesn't see it because the `db` parameter has no type… | |||||
] | |||||
@timed | @timed | ||||
@process_metrics | @process_metrics | ||||
@db_transaction() | @db_transaction() | ||||
def metadata_fetcher_add( | def metadata_fetcher_add( | ||||
self, fetchers: List[MetadataFetcher], db=None, cur=None | self, fetchers: List[MetadataFetcher], db=None, cur=None | ||||
) -> Dict[str, int]: | ) -> Dict[str, int]: | ||||
fetchers = list(fetchers) | fetchers = list(fetchers) | ||||
self.journal_writer.metadata_fetcher_add(fetchers) | self.journal_writer.metadata_fetcher_add(fetchers) | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
That call to str(target) looks suspicious. I think it should rather be in db.raw_extrinsic_metadata_get_authorities(target.object_id, cur) but I might miss something here.