Skip to content

Commit

Permalink
fixup! Push down HCA specifics to a Bundle subclass (#4940)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Jun 2, 2023
1 parent 04ad9a9 commit e028a04
Show file tree
Hide file tree
Showing 67 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scripts/can_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from azul.plugins import (
RepositoryPlugin,
)
from azul.plugins.anvil import (
from azul.plugins.metadata.anvil.bundle import (
AnvilBundle,
)
from azul.types import (
Expand Down
3 changes: 2 additions & 1 deletion src/azul/indexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,12 @@ def _reject_joiner(self, value: AnyJSON):
msg = f'{config.manifest_column_joiner!r} is disallowed in metadata'
raise RequirementError(msg, self.fqid)

@abstractmethod
def reject_joiner(self):
"""
Raise a requirement error if the given string is found in the bundle
"""
self._reject_joiner(self.to_json())
raise NotImplementedError

@classmethod
@abstractmethod
Expand Down
8 changes: 6 additions & 2 deletions src/azul/plugins/metadata/anvil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MetadataPlugin,
Sorting,
)
from azul.plugins.anvil import (
from azul.plugins.metadata.anvil.bundle import (
AnvilBundle,
)
from azul.plugins.metadata.anvil.indexer.transform import (
Expand Down Expand Up @@ -67,7 +67,11 @@ def transformer_types(self) -> Iterable[Type[BaseTransformer]]:
FileTransformer,
)

def transformers(self, bundle: AnvilBundle, *, delete: bool) -> Iterable[BaseTransformer]:
def transformers(self,
bundle: AnvilBundle,
*,
delete: bool
) -> Iterable[BaseTransformer]:
return [
transformer_cls(bundle=bundle, deleted=delete)
for transformer_cls in self.transformer_types()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class AnvilBundle(Bundle[BUNDLE_FQID], ABC):
entities: dict[EntityReference, MutableJSON] = attr.ib(factory=dict)
links: set[Link[EntityReference]] = attr.ib(factory=set)

def reject_joiner(self):
pass

def to_json(self) -> MutableJSON:
return {
'entities': {
Expand Down
2 changes: 1 addition & 1 deletion src/azul/plugins/metadata/anvil/indexer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from azul.indexer.transform import (
Transformer,
)
from azul.plugins.anvil import (
from azul.plugins.metadata.anvil.bundle import (
AnvilBundle,
Link,
)
Expand Down
8 changes: 6 additions & 2 deletions src/azul/plugins/metadata/hca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MetadataPlugin,
Sorting,
)
from azul.plugins.hca import (
from azul.plugins.metadata.hca.bundle import (
HCABundle,
)
from azul.plugins.metadata.hca.indexer.aggregate import (
Expand Down Expand Up @@ -64,7 +64,11 @@ def transformer_types(self) -> Iterable[Type[BaseTransformer]]:
BundleTransformer
)

def transformers(self, bundle: HCABundle, *, delete: bool) -> Iterable[BaseTransformer]:
def transformers(self,
bundle: HCABundle,
*,
delete: bool
) -> Iterable[BaseTransformer]:
api_bundle = api.Bundle(uuid=bundle.uuid,
version=bundle.version,
manifest=bundle.manifest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class HCABundle(Bundle[BUNDLE_FQID], ABC):
"""
metadata_files: MutableJSON

def reject_joiner(self):
self._reject_joiner(self.manifest)
self._reject_joiner(self.metadata_files)

def to_json(self) -> MutableJSON:
return {
'manifest': self.manifest,
Expand Down
2 changes: 1 addition & 1 deletion src/azul/plugins/metadata/hca/indexer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
from azul.openapi import (
schema,
)
from azul.plugins.hca import (
from azul.plugins.metadata.hca.bundle import (
HCABundle,
)
from azul.plugins.metadata.hca.indexer.aggregate import (
Expand Down
4 changes: 2 additions & 2 deletions src/azul/plugins/repository/canned/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
RepositoryFileDownload,
RepositoryPlugin,
)
from azul.plugins.hca import (
from azul.plugins.metadata.hca.bundle import (
HCABundle,
)
from azul.time import (
Expand Down Expand Up @@ -81,7 +81,7 @@ class CannedBundle(HCABundle[CannedBundleFQID]):

@classmethod
def canning_qualifier(cls) -> str:
return 'gh'
return 'gh.hca'

def drs_path(self, manifest_entry: JSON) -> Optional[str]:
return 'dss'
Expand Down
4 changes: 2 additions & 2 deletions src/azul/plugins/repository/dss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
RepositoryFileDownload,
RepositoryPlugin,
)
from azul.plugins.hca import (
from azul.plugins.metadata.hca.bundle import (
HCABundle,
)
from azul.time import (
Expand Down Expand Up @@ -86,7 +86,7 @@ class DSSBundle(HCABundle[DSSBundleFQID]):

@classmethod
def canning_qualifier(cls) -> str:
return 'dss'
return 'dss.hca'

def drs_path(self, manifest_entry: JSON) -> str:
file_uuid = manifest_entry['uuid']
Expand Down
6 changes: 5 additions & 1 deletion src/azul/plugins/repository/tdr_anvil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
EntityReference,
EntityType,
)
from azul.plugins.anvil import (
from azul.plugins.metadata.anvil.bundle import (
AnvilBundle,
Key,
KeyReference,
Expand Down Expand Up @@ -115,6 +115,10 @@ class TDRAnvilBundle(AnvilBundle[AnvilBundleFQID], TDRBundle):
def extension(cls) -> str:
return 'tdr.anvil'

@classmethod
def canning_qualifier(cls) -> str:
return super().canning_qualifier() + '.anvil'

def add_entity(self,
entity: EntityReference,
version: str,
Expand Down
6 changes: 5 additions & 1 deletion src/azul/plugins/repository/tdr_hca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
EntityReference,
EntityType,
)
from azul.plugins.hca import (
from azul.plugins.metadata.hca.bundle import (
HCABundle,
)
from azul.plugins.repository.tdr import (
Expand Down Expand Up @@ -177,6 +177,10 @@ def extract_field(field: attr.Attribute) -> tuple[str, Any]:

class TDRHCABundle(HCABundle[TDRBundleFQID], TDRBundle):

@classmethod
def canning_qualifier(cls) -> str:
return super().canning_qualifier() + '.hca'

def add_entity(self,
*,
entity_key: str,
Expand Down
2 changes: 1 addition & 1 deletion test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
MetadataPlugin,
RepositoryPlugin,
)
from azul.plugins.anvil import (
from azul.plugins.metadata.anvil.bundle import (
Link,
)
from azul.plugins.repository.tdr import (
Expand Down

0 comments on commit e028a04

Please sign in to comment.