Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename top-level command and add subcommand #30

Merged
merged 38 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7580796
rf: rename top-level command to `dandisets-report-tools`
candleindark Nov 27, 2024
b80f045
rf: rename the original main command to `linkml_translation`
candleindark Nov 27, 2024
3afd78e
feat: add new command to run validation against manifest directory
candleindark Nov 27, 2024
01dfa00
style: re-organize imports
candleindark Dec 1, 2024
acfa00e
chore: update code to Python syntax 3.10
candleindark Dec 1, 2024
79b2a4d
rf: remove `pydantic_validate()` in `cli/tools.py`
candleindark Dec 1, 2024
337a3cd
rf: move `check_source_jsonschema_validation_error`
candleindark Dec 2, 2024
67d818a
rf: move `polish_validation_results()` and supporting defs
candleindark Dec 2, 2024
e6f1838
rf: move `JsonValidationErrorView`
candleindark Dec 2, 2024
7eba761
rf: move `JsonschemaValidationErrorType`
candleindark Dec 2, 2024
ba6d8a3
rf: rename `cli.models.DandisetValidationReport`
candleindark Dec 2, 2024
3000dab
rf: move `DandisetLinkmlTranslationReport`
candleindark Dec 2, 2024
9bc471e
rf: move `DandisetMetadataType`
candleindark Dec 2, 2024
32d723d
rf: move `LinkmlValidationErrsType`
candleindark Dec 2, 2024
7b37045
rf: move type adapters from `cli/models.py` to `models.py`
candleindark Dec 2, 2024
5384243
rf: delete `cli/models.py`
candleindark Dec 2, 2024
a01b427
rf: move `DandiModelLinkmlValidator`
candleindark Dec 2, 2024
4113bd7
rf: move `compile_dandiset_validation_report`
candleindark Dec 2, 2024
b79f302
rf: rename `compile_dandiset_validation_report`
candleindark Dec 2, 2024
8d9387e
rf: move `isorted`
candleindark Dec 2, 2024
64c2339
rf: move `get_pydantic_err_counts()`
candleindark Dec 2, 2024
1e5589f
rf: move `get_linkml_err_counts()` and supporting def
candleindark Dec 2, 2024
e1926c9
rf: move `output_dandi_linkml_schema()` and supporting def
candleindark Dec 2, 2024
f8c556e
rf: move `DANDI_MODULE_NAMES`
candleindark Dec 2, 2024
0a243fb
rf: move `output_reports()` and supporting defs
candleindark Dec 2, 2024
480c41e
rf: remove `cli/tools.py`
candleindark Dec 2, 2024
92d07aa
rf: remove unneeded `Iterable` import from `typing`
candleindark Dec 2, 2024
b3299e6
rf: change import path for `JsonschemaValidationPlugin`
candleindark Dec 2, 2024
6b0b231
style: reorder import statements
candleindark Dec 2, 2024
358f671
rf: import `DandisetValidationReport` in `__init__.py` directly
candleindark Dec 2, 2024
01dc6ff
rf: move import and adapter statement out of temp setup
candleindark Dec 2, 2024
21615c5
rf: define and utilize `DandiBaseReport`
candleindark Dec 2, 2024
aee9806
feat: allow `manifests` subcommand to take in manifest directory path…
candleindark Dec 3, 2024
f373e72
doc: provide help doc for each subcommand
candleindark Dec 3, 2024
6556fe5
rf: bring `--log-level` option to application level
candleindark Dec 3, 2024
ddd3cb8
feat: add `output_dir_path` as a command option
candleindark Dec 3, 2024
ada390e
fix: create parents when needed in creating output dir
candleindark Dec 3, 2024
6201c13
feat: let report output path dependent on provided option value
candleindark Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rf: move output_dandi_linkml_schema() and supporting def
From `cli/tools.py` to `tools.py`
  • Loading branch information
candleindark committed Dec 2, 2024
commit e1926c970a62232645f5193447199011031a89ed
23 changes: 3 additions & 20 deletions src/dandisets_linkml_status_tools/cli/tools.py
Original file line number Diff line number Diff line change
@@ -5,13 +5,13 @@
from shutil import rmtree
from typing import Any

from linkml_runtime.dumpers import yaml_dumper
from pydantic import TypeAdapter
from yaml import dump as yaml_dump

from dandisets_linkml_status_tools.tools import (
DandiModelLinkmlValidator,
get_pydantic_err_counts, get_linkml_err_counts,
get_pydantic_err_counts,
get_linkml_err_counts,
output_dandi_linkml_schema,
)

try:
@@ -160,21 +160,6 @@ def output_reports(
logger.info("Output of dandiset validation reports completed")


def output_dandi_linkml_schema(output_path: Path) -> None:
"""
Output the DANDI LinkML schema, in YAML, to a file

:param output_path: The path specifying the location of the file
"""
# Output the LinkML schema used in the validations
dandi_linkml_schema_yml = yaml_dumper.dumps(
DandiModelLinkmlValidator.get_dandi_linkml_schema()
)
with output_path.open("w") as f:
f.write(dandi_linkml_schema_yml)
logger.info("Output the DANDI LinkML schema to %s", output_path)


def _write_data(
data: Any, data_adapter: TypeAdapter, base_file_name: str, output_dir: Path
) -> None:
@@ -208,5 +193,3 @@ def _gen_row(cell_str_values: Iterable[str]) -> str:
Note: The given iterable of cell string values are `str` values
"""
return f'|{"|".join(cell_str_values)}|\n'


20 changes: 19 additions & 1 deletion src/dandisets_linkml_status_tools/tools.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
from linkml.validator import JsonschemaValidationPlugin, Validator
from linkml.validator.plugins import ValidationPlugin
from linkml.validator.report import ValidationResult
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.linkml_model import SchemaDefinition

from pydantic import BaseModel, TypeAdapter, ValidationError
@@ -22,7 +23,9 @@
from .models import (
ValidationReport,
DandisetLinkmlTranslationReport,
PydanticValidationErrsType, JsonschemaValidationErrorType, LinkmlValidationErrsType,
PydanticValidationErrsType,
JsonschemaValidationErrorType,
LinkmlValidationErrsType,
)

logger = logging.getLogger(__name__)
@@ -305,3 +308,18 @@ def sorting_key(
count_err(e)

return compile_counts()


def output_dandi_linkml_schema(output_path: Path) -> None:
"""
Output the DANDI LinkML schema, in YAML, to a file

:param output_path: The path specifying the location of the file
"""
# Output the LinkML schema used in the validations
dandi_linkml_schema_yml = yaml_dumper.dumps(
DandiModelLinkmlValidator.get_dandi_linkml_schema()
)
with output_path.open("w") as f:
f.write(dandi_linkml_schema_yml)
logger.info("Output the DANDI LinkML schema to %s", output_path)