This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Simplify __repr__ and test for __repr__ (#405)
* ✨ Simplify __repr__ Signed-off-by: zethson <[email protected]> * ✨ Add test for __repr__ Signed-off-by: zethson <[email protected]> * 🎨 Fix session Signed-off-by: zethson <[email protected]> * 🎨 Fix login Signed-off-by: zethson <[email protected]> * 🎨 Don't need a session maybe? Signed-off-by: zethson <[email protected]> * 🎨 Install lamindb in nox session Signed-off-by: zethson <[email protected]> * 🎨 System Signed-off-by: zethson <[email protected]> * 🎨 Tests Signed-off-by: zethson <[email protected]> * 🎨 Strip ansi Signed-off-by: zethson <[email protected]> * 🎨 Test bionty in __repr__ Signed-off-by: zethson <[email protected]> * 🎨 Test bionty in __repr__ Signed-off-by: zethson <[email protected]> * 🎨 Rename to bionty instance Signed-off-by: zethson <[email protected]> * 🎨 Scope instances Signed-off-by: zethson <[email protected]> * 🎨 Test function scope Signed-off-by: zethson <[email protected]> * 🎨 Only integrity instance Signed-off-by: zethson <[email protected]> * 🎨 Only integrity instance Signed-off-by: zethson <[email protected]> * 🎨 Add comment Signed-off-by: zethson <[email protected]> --------- Signed-off-by: zethson <[email protected]>
- Loading branch information
Showing
6 changed files
with
112 additions
and
19 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
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
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,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() |