-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: manifest and consolidate methods
- Loading branch information
Showing
8 changed files
with
262 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,5 @@ perfs_benchmark.log | |
bench/ | ||
.chromnn | ||
*.keras | ||
*.fa | ||
*.fa.fai |
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,37 @@ | ||
import logging | ||
import click | ||
|
||
from momics import momics as m | ||
|
||
from . import cli | ||
|
||
|
||
@cli.command() | ||
@click.option( | ||
"--vacuum", | ||
"-v", | ||
help="Flag to indicate wether fragments should be vacuumed after consolidation.", | ||
is_flag=True, | ||
required=False, | ||
) | ||
@click.argument("path", metavar="MOMICS_REPO", required=True) | ||
@click.pass_context | ||
def consolidate(ctx, path, vacuum): | ||
"""Consolidate a momics repository. | ||
Consolidation is the process of compacting all the fragments from the repository | ||
to remove any unused space. This process is useful to reduce the size of the | ||
repository and improve performance. | ||
The vacuum flag indicates wether the consolidated | ||
array should be vacuumed after consolidation. This process is useful to further | ||
reduce the size of the repository. | ||
""" | ||
|
||
mom = m.Momics(path) | ||
s = mom.size() | ||
mom.consolidate(vacuum=vacuum) | ||
sf = mom.size() | ||
logging.info(f"Final repository size: {sf/(1024*1024)} Mb.") | ||
logging.info(f"Space saved after consolidation: {(s - sf)/(1024*1024)} Mb.") | ||
return True |
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,48 @@ | ||
import json | ||
import os | ||
import click | ||
|
||
from momics import momics as m | ||
|
||
from . import cli | ||
|
||
|
||
@cli.command() | ||
@click.option( | ||
"--output", | ||
"-o", | ||
help="Path of output JSON file to write.", | ||
type=str, | ||
required=False, | ||
) | ||
@click.option( | ||
"--force", | ||
"-f", | ||
help="Force overwrite of existing files.", | ||
is_flag=True, | ||
default=False, | ||
show_default=True, | ||
) | ||
@click.argument("path", metavar="MOMICS_REPO", required=True) | ||
@click.pass_context | ||
def manifest(ctx, path, output, force): | ||
"""Print the manifest of a momics repository.""" | ||
|
||
if not force and output: | ||
if os.path.exists(output): | ||
click.confirm( | ||
f"{output} file already exists. Are you sure you want to overwrite it", | ||
abort=True, | ||
) | ||
os.remove(output) | ||
|
||
mom = m.Momics(path) | ||
man = mom.manifest() | ||
|
||
if not output: | ||
print(json.dumps(man, indent=2)) | ||
return None | ||
else: | ||
with open(output, "w") as f: | ||
json.dump(man, f, indent=2) | ||
return True |
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
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