-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[r] Fix: Partition sizing ignores supplementary bundles (#5207)
- Loading branch information
1 parent
4f3d562
commit b1c28fe
Showing
6 changed files
with
140 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../anvildev/sources.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"anvil": [ | ||
"datarepo-1ba591a6.ANVIL_1000G_high_coverage_2019_20221019_ANV5_202303081523", | ||
"datarepo-aa67671a.ANVIL_CMG_UWASH_DS_BAV_IRB_PUB_RD_20221020_ANV5_202303081451", | ||
"datarepo-b4e0bfd5.ANVIL_CMG_UWASH_DS_BDIS_20221020_ANV5_202303081501", | ||
"datarepo-333dd883.ANVIL_CMG_UWASH_DS_HFA_20221020_ANV5_202303081456", | ||
"datarepo-b968cbdb.ANVIL_CMG_UWASH_DS_NBIA_20221020_ANV5_202303081459", | ||
"datarepo-6a5b13ea.ANVIL_CMG_UWASH_HMB_20221020_ANV5_202303081455", | ||
"datarepo-3d4c42f7.ANVIL_CMG_UWASH_HMB_IRB_20221020_ANV5_202303081454", | ||
"datarepo-080b2c9e.ANVIL_CMG_UWash_DS_EP_20221020_ANV5_202303081452", | ||
"datarepo-4f75c9e3.ANVIL_CMG_UWash_GRU_20230308_ANV5_202303081731", | ||
"datarepo-ec9365be.ANVIL_CMG_UWash_GRU_IRB_20221020_ANV5_202303081458", | ||
"datarepo-8392ac2c.ANVIL_GTEx_V8_hg38_20221013_ANV5_202303081502" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
""" | ||
Determine sizes | ||
""" | ||
|
||
import argparse | ||
import json | ||
from pathlib import ( | ||
Path, | ||
) | ||
import sys | ||
|
||
import attr | ||
|
||
from azul import ( | ||
config, | ||
) | ||
from azul.args import ( | ||
AzulArgumentHelpFormatter, | ||
) | ||
from azul.azulclient import ( | ||
AzulClient, | ||
) | ||
from azul.indexer import ( | ||
Prefix, | ||
) | ||
from azul.terra import ( | ||
TDRSourceSpec, | ||
) | ||
|
||
parser = argparse.ArgumentParser(description=__doc__, | ||
formatter_class=AzulArgumentHelpFormatter) | ||
|
||
parser.add_argument('--catalogs', | ||
nargs='+', | ||
metavar='NAME', | ||
default=[ | ||
c for c in config.catalogs | ||
if c not in config.integration_test_catalogs | ||
], | ||
help='The names of the catalogs to determine source specs for.') | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True, kw_only=True) | ||
class SourceSpecArgs: | ||
project: str | ||
snapshot: str | ||
subgraph_count: int | ||
|
||
def __str__(self) -> str: | ||
return f'mksrc({self.project!r}, {self.snapshot!r}, {self.subgraph_count!r})' | ||
|
||
|
||
azul = AzulClient() | ||
|
||
active_deployment_dir = Path(config.project_root) / 'deployments' / '.active' | ||
with open(active_deployment_dir / 'sources.json') as f: | ||
raw_sources = json.load(f) | ||
|
||
|
||
def generate_sources(catalog: str) -> list[SourceSpecArgs]: | ||
catalog_sources = raw_sources[catalog] | ||
plugin = azul.repository_plugin(catalog) | ||
sources = [] | ||
for source in catalog_sources: | ||
project, snapshot = source.split('.') | ||
spec = TDRSourceSpec(project=project, | ||
name=snapshot, | ||
is_snapshot=True, | ||
prefix=Prefix.of_everything) | ||
ref = plugin.resolve_source(str(spec)) | ||
partitions = plugin.list_partitions(ref) | ||
sources.append(SourceSpecArgs(project=project, | ||
snapshot=snapshot, | ||
subgraph_count=sum(partitions.values()))) | ||
|
||
return sources | ||
|
||
|
||
def main(args: list[str]): | ||
args = parser.parse_args(args) | ||
|
||
for catalog in args.catalogs: | ||
print(catalog) | ||
print('-' * len(catalog)) | ||
spec_args_list = generate_sources(catalog) | ||
spec_args_list.sort(key=lambda spec_args: spec_args.snapshot) | ||
print(',\n'.join(map(str, spec_args_list))) | ||
|
||
msg = "Don't forget to manually specify flags for `ma` and `pop`." | ||
print('-' * len(msg)) | ||
print(msg) | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters