From fdeacb7719e17ea5998b0e2861f56d5701ab3e80 Mon Sep 17 00:00:00 2001 From: Sunny Sun <38218185+sunnyosun@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:25:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Clean=20up=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ter_artifactbiosample_artifact_and_more.py | 1 - clinicore/models.py | 46 ++++++++----------- docs/quickstart.ipynb | 22 +++++---- pyproject.toml | 10 ++-- 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/clinicore/migrations/0007_alter_artifactbiosample_artifact_and_more.py b/clinicore/migrations/0007_alter_artifactbiosample_artifact_and_more.py index 3e194c4..41c09a8 100644 --- a/clinicore/migrations/0007_alter_artifactbiosample_artifact_and_more.py +++ b/clinicore/migrations/0007_alter_artifactbiosample_artifact_and_more.py @@ -10,7 +10,6 @@ class Migration(migrations.Migration): - dependencies = [ ("bionty", "0041_alter_artifactcellline_artifact_and_more"), ("clinicore", "0006_artifactbiosample_artifactclinicaltrial_and_more"), diff --git a/clinicore/models.py b/clinicore/models.py index e016c0a..fb28d1d 100644 --- a/clinicore/models.py +++ b/clinicore/models.py @@ -48,13 +48,13 @@ class Meta(Record.Meta, TracksRun.Meta, TracksUpdates.Meta): """Internal id, valid only in one DB instance.""" uid: str = CharField(unique=True, max_length=8, default=ids.base62_8) """Universal id, valid across DB instances.""" - name: str | None = CharField(max_length=255, default=None, db_index=True) + name: str | None = CharField(max_length=255, db_index=True) """ClinicalTrials.gov ID, the format is "NCT" followed by an 8-digit number.""" - title: str | None = TextField(null=True, default=None) + title: str | None = TextField(null=True) """Official title of the clinical trial.""" - objective: str | None = TextField(null=True, default=None) + objective: str | None = TextField(null=True) """Objective of the clinical trial.""" - description: str | None = TextField(null=True, default=None) + description: str | None = TextField(null=True) """Description of the clinical trial.""" collections: Collection = models.ManyToManyField( Collection, related_name="clinical_trials" @@ -99,11 +99,11 @@ class Biosample(Record, CanCurate, TracksRun, TracksUpdates): """Internal id, valid only in one DB instance.""" uid: str = CharField(unique=True, max_length=12, default=ids.base62_12) """Universal id, valid across DB instances.""" - name: str | None = CharField(max_length=255, default=None, db_index=True, null=True) + name: str | None = CharField(db_index=True, null=True) """Name of the biosample.""" - batch: str | None = CharField(max_length=60, default=None, null=True, db_index=True) + batch: str | None = CharField(max_length=60, null=True, db_index=True) """Batch label of the biosample.""" - description: str | None = TextField(null=True, default=None) + description: str | None = TextField(null=True) """Description of the biosample.""" patient: Patient = ForeignKey( "Patient", PROTECT, related_name="biosamples", null=True, default=None @@ -167,12 +167,12 @@ class Patient(Record, CanCurate, TracksRun, TracksUpdates): """Internal id, valid only in one DB instance.""" uid: str = CharField(unique=True, max_length=12, default=ids.base62_12) """Universal id, valid across DB instances. Use this field to model internal patient IDs.""" - name: str | None = CharField(max_length=255, default=None, db_index=True) + name: str | None = CharField(db_index=True) """Name of the patient.""" age: int | None = IntegerField(null=True, default=None, db_index=True) """Age of the patient.""" gender: str | None = CharField( - max_length=10, choices=GENDER_CHOICES, null=True, default=None, db_index=True + max_length=10, choices=GENDER_CHOICES, null=True, db_index=True ) """Gender of the patient.""" ethnicity: Ethnicity = ForeignKey(Ethnicity, PROTECT, null=True, default=None) @@ -220,21 +220,15 @@ class Meta(BioRecord.Meta, TracksRun.Meta, TracksUpdates.Meta): """A universal id (hash of selected field).""" name: str = CharField(max_length=256, db_index=True) """Name of the medication.""" - ontology_id: str | None = CharField( - max_length=32, db_index=True, null=True, default=None - ) + ontology_id: str | None = CharField(max_length=32, db_index=True, null=True) """Ontology ID of the medication.""" - chembl_id: str | None = CharField( - max_length=32, db_index=True, null=True, default=None - ) + chembl_id: str | None = CharField(max_length=32, db_index=True, null=True) """ChEMBL ID of the medication.""" - abbr: str | None = CharField( - max_length=32, db_index=True, unique=True, null=True, default=None - ) + abbr: str | None = CharField(max_length=32, db_index=True, unique=True, null=True) """A unique abbreviation of medication.""" - synonyms: str | None = TextField(null=True, default=None) + synonyms: str | None = TextField(null=True) """Bar-separated (|) synonyms that correspond to this medication.""" - description: str | None = TextField(null=True, default=None) + description: str | None = TextField(null=True) """Description of the medication.""" parents: Medication = models.ManyToManyField( "self", symmetrical=False, related_name="children" @@ -311,11 +305,9 @@ class Treatment(Record, CanCurate, TracksRun, TracksUpdates): """Internal id, valid only in one DB instance.""" uid: str = CharField(unique=True, max_length=12, default=ids.base62_12) """Universal id, valid across DB instances.""" - name: str | None = CharField(max_length=255, default=None, db_index=True) + name: str | None = CharField(db_index=True) """Name of the treatment.""" - status: str | None = CharField( - max_length=16, choices=STATUS_CHOICES, null=True, default=None - ) + status: str | None = CharField(max_length=16, choices=STATUS_CHOICES, null=True) """Status of the treatment.""" medication: Medication | None = ForeignKey( Medication, PROTECT, null=True, default=None @@ -323,15 +315,15 @@ class Treatment(Record, CanCurate, TracksRun, TracksUpdates): """Medications linked to the treatment.""" dosage: float | None = FloatField(null=True, default=None) """Dosage of the treatment.""" - dosage_unit: str | None = CharField(max_length=32, null=True, default=None) + dosage_unit: str | None = CharField(max_length=32, null=True) """Unit of the dosage.""" administered_datetime: datetime | None = DateTimeField(null=True, default=None) """Date and time the treatment was administered.""" duration: DurationField = DurationField(null=True, default=None) """Duration of the treatment.""" - route: str | None = CharField(max_length=32, null=True, default=None) + route: str | None = CharField(max_length=32, null=True) """Route of administration of the treatment.""" - site: str | None = CharField(max_length=32, null=True, default=None) + site: str | None = CharField(max_length=32, null=True) """Body site of administration of the treatment.""" artifacts: Artifact = models.ManyToManyField( Artifact, through="ArtifactTreatment", related_name="treatments" diff --git a/docs/quickstart.ipynb b/docs/quickstart.ipynb index 6281d21..7f8624b 100644 --- a/docs/quickstart.ipynb +++ b/docs/quickstart.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "7f26a335-cf1c-4e69-be3b-0c26b154606a", + "id": "0", "metadata": {}, "source": [ "# Quickstart" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f37ebcaa", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a51faaf3-ee27-43c6-b48d-13be1adb5c46", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a1e61ead", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -41,17 +41,19 @@ { "cell_type": "code", "execution_count": null, - "id": "c71693bf", + "id": "4", "metadata": {}, "outputs": [], "source": [ - "clinical_trail = cl.ClinicalTrial(name=\"NCT00000000\", title=\"This is a test clinical trial\").save()" + "clinical_trail = cl.ClinicalTrial(\n", + " name=\"NCT00000000\", title=\"This is a test clinical trial\"\n", + ").save()" ] }, { "cell_type": "code", "execution_count": null, - "id": "5d3f489d", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -61,7 +63,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7f19edc5", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -74,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47078824", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81d079b6", + "id": "8", "metadata": {}, "outputs": [], "source": [ diff --git a/pyproject.toml b/pyproject.toml index 94ed546..f1ccf5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [{name = "Lamin Labs", email = "open-source@lamin.ai"}] readme = "README.md" dynamic = ["version", "description"] dependencies = [ - "lamindb[bionty,aws]", + "lamindb[bionty]>=0.77.0", ] [project.urls] @@ -31,7 +31,7 @@ testpaths = [ [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 @@ -48,7 +48,7 @@ select = [ "PTH", # Use pathlib "S" # Security ] -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. @@ -119,10 +119,10 @@ ignore = [ "S607", ] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/*" = ["I"] "tests/**/*.py" = [ "D", # docstrings are allowed to look a bit off