mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-16 21:37:59 +08:00
This splits the backend into two parts: the local backend for desktop cellxgene and the AWS backend for hosted cellxgene. The local backend is in local_server while the hosted remains in server. The general idea is to copy everything from server to local_server, pull unneeded stuff out of local_server, and keep server as-is for this PR. Not touching server means all the infra and deployment code will continue working just as it did before so we can make those changes incrementally.
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
import click
|
|
|
|
from local_server.converters.schema import remix, validate
|
|
|
|
|
|
@click.group(
|
|
name="schema",
|
|
subcommand_metavar="COMMAND <args>",
|
|
short_help="Apply and validate the cellxgene data integration schema to an h5ad file.",
|
|
context_settings=dict(max_content_width=85, help_option_names=["-h", "--help"]),
|
|
)
|
|
def schema_cli():
|
|
try:
|
|
import scanpy # noqa: F401
|
|
except ImportError:
|
|
raise click.ClickException(
|
|
"[cellxgene] cellxgene schema requires scanpy"
|
|
)
|
|
|
|
|
|
@click.command(
|
|
name="apply",
|
|
short_help="(experimental) Apply the cellxgene data integration schema to an h5ad.",
|
|
help="(experimental) Using a yaml file that describes schema values to insert or convert and in input "
|
|
"h5ad file, apply the schema changes and create a new, conforming h5ad.",
|
|
)
|
|
@click.option(
|
|
"--source-h5ad",
|
|
help="Input h5ad file.",
|
|
nargs=1,
|
|
required=True,
|
|
type=click.Path(exists=True, dir_okay=False),
|
|
)
|
|
@click.option(
|
|
"--remix-config",
|
|
help="Config yaml with information on how to apply the schema.",
|
|
nargs=1,
|
|
required=True,
|
|
type=click.Path(exists=True, dir_okay=False),
|
|
)
|
|
@click.option(
|
|
"--output-filename",
|
|
help="Filename for the new, schema-conforming h5ad file.",
|
|
required=True,
|
|
nargs=1
|
|
)
|
|
def schema_apply(source_h5ad, remix_config, output_filename):
|
|
remix.apply_schema(source_h5ad, remix_config, output_filename)
|
|
|
|
|
|
@click.command(
|
|
name="validate",
|
|
short_help="(experimental) Check that an h5ad follows the cellxgene data integration schema.",
|
|
)
|
|
@click.argument(
|
|
"h5ad",
|
|
nargs=1,
|
|
type=click.Path(exists=True, dir_okay=False),
|
|
)
|
|
@click.option(
|
|
"--shallow",
|
|
help="When true, just check that the correct version information is present.",
|
|
default=False,
|
|
show_default=True,
|
|
is_flag=True,
|
|
)
|
|
def schema_validate(h5ad, shallow):
|
|
validate.validate(h5ad, shallow)
|
|
|
|
|
|
schema_cli.add_command(schema_apply)
|
|
schema_cli.add_command(schema_validate)
|