diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d64f39a6..a78ddd0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,16 +14,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10"] + python-version: ["3.11"] timeout-minutes: 15 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: "pip" - cache-dependency-path: ".github/workflows/build.yml" # See dependencies below - name: cache pre-commit uses: actions/cache@v3 with: diff --git a/lnschema_core/models.py b/lnschema_core/models.py index 9938784d..f039b296 100644 --- a/lnschema_core/models.py +++ b/lnschema_core/models.py @@ -621,11 +621,11 @@ def _get_related_field_type(field) -> str: ) non_external_schema_fields_formatted = [ - f" .{field.name.replace('_links', '')}: {_get_related_field_type(field)}\n" + f" .{field.name}: {_get_related_field_type(field)}\n" for field in non_external_schema_fields ] external_schema_fields_formatted = [ - f" .{field.name.replace('_links', '')}: {_get_related_field_type(field)}\n" + f" .{field.name}: {_get_related_field_type(field)}\n" for field in external_schema_fields ] diff --git a/noxfile.py b/noxfile.py index 4f1c901b..ebcd68e9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,5 @@ import nox -from laminci.nox import login_testuser1, run, run_pre_commit, run_pytest +from laminci.nox import run, run_pre_commit, run_pytest nox.options.default_venv_backend = "none" @@ -11,9 +11,9 @@ def lint(session: nox.Session) -> None: @nox.session def test(session: nox.Session) -> None: - run(session, "pip install -e .[dev]") + run(session, "uv pip install --system -e .[dev]") run( session, - "pip install lamindb_setup@git+https://github.com/laminlabs/lamindb-setup", + "uv pip install --system lamindb[bionty]@git+https://github.com/laminlabs/lamindb", ) run_pytest(session, coverage=False) diff --git a/pyproject.toml b/pyproject.toml index bb9bf85c..33129fc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] # mandate zero dependencies dependencies = [ @@ -44,7 +45,7 @@ omit = [ [tool.ruff] src = ["src"] line-length = 88 -select = [ +lint.select = [ "F", # Errors detected by Pyflakes "E", # Error detected by Pycodestyle "W", # Warning detected by Pycodestyle @@ -60,7 +61,7 @@ select = [ "NPY", # Numpy specific rules "PTH" # Use pathlib ] -ignore = [ +lint.ignore = [ # Do not catch blind exception: `Exception` "BLE001", # Errors from function calls in argument defaults. These are fine when the result is immutable. @@ -129,10 +130,10 @@ ignore = [ "PTH123", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/*" = ["I"] "tests/*" = ["D"] "*/__init__.py" = ["F401"] diff --git a/tests/test_integrity.py b/tests/test_integrity.py index 5cf852dc..259b46a5 100644 --- a/tests/test_integrity.py +++ b/tests/test_integrity.py @@ -3,15 +3,15 @@ @pytest.fixture(scope="module") -def setup_instance(): - ln_setup.init(storage="./testdb") +def setup_bionty_instance(): + ln_setup.init(storage="./test-bionty-db", schema="bionty") yield - ln_setup.delete("testdb", force=True) + ln_setup.delete("test-bionty-db", force=True) -def test_migrate_check(setup_instance): +def test_migrate_check(setup_bionty_instance): assert ln_setup.migrate.check() -def test_system_check(setup_instance): +def test_system_check(setup_bionty_instance): ln_setup.django("check") diff --git a/tests/test_models.py b/tests/test_models.py new file mode 100644 index 00000000..e78c705d --- /dev/null +++ b/tests/test_models.py @@ -0,0 +1,94 @@ +import re +import textwrap + +import lamindb as ln + +# The tests defined in this script use the lamindb instance defined in test_integrity + + +def _strip_ansi(text: str) -> str: + """Remove ANSI escape sequences from a string.""" + ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") + return ansi_escape.sub("", text) + + +def test_registry__repr__param(): + param = ln.Param + expected_repr = textwrap.dedent("""\ + Param + Basic fields + .id: BigAutoField + .name: CharField + .dtype: CharField + .created_at: DateTimeField + .updated_at: DateTimeField + Relational fields + .created_by: User + .run: Run + .previous_runs: Run + .paramvalue: ParamValue + """).strip() + + actual_repr = _strip_ansi(repr(param)) + assert actual_repr.strip() == expected_repr.strip() + + +def test_registry__repr__artifact(): + artifact = ln.Artifact + expected_repr = textwrap.dedent("""\ + Artifact + Basic fields + .id: AutoField + .uid: CharField + .description: CharField + .key: CharField + .suffix: CharField + .type: CharField + .accessor: CharField + .size: BigIntegerField + .hash: CharField + .hash_type: CharField + .n_objects: BigIntegerField + .n_observations: BigIntegerField + .visibility: SmallIntegerField + .key_is_virtual: BooleanField + .version: CharField + .created_at: DateTimeField + .updated_at: DateTimeField + Relational fields + .created_by: User + .storage: Storage + .transform: Transform + .run: Run + .ulabels: ULabel + .input_of: Run + .previous_runs: Run + .feature_sets: FeatureSet + .feature_values: FeatureValue + .param_values: ParamValue + .latest_report_of: Transform + .source_code_of: Transform + .report_of: Run + .environment_of: Run + .collection: Collection + .collections: Collection + Bionty fields + .organisms: bionty.Organism + .genes: bionty.Gene + .proteins: bionty.Protein + .cell_markers: bionty.CellMarker + .tissues: bionty.Tissue + .cell_types: bionty.CellType + .diseases: bionty.Disease + .cell_lines: bionty.CellLine + .phenotypes: bionty.Phenotype + .pathways: bionty.Pathway + .experimental_factors: bionty.ExperimentalFactor + .developmental_stages: bionty.DevelopmentalStage + .ethnicities: bionty.Ethnicity + .reference_of_source: bionty.Source + .reference_of_sources: bionty.Source + """).strip() + + actual_repr = _strip_ansi(repr(artifact)) + assert actual_repr.strip() == expected_repr.strip()