From 2104eef7feff0ba2771bf20e2339926031992d6d Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 26 Sep 2024 21:39:55 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Enable=20to=20laming=20get=20fr?= =?UTF-8?q?om=20lamin.ai=20domains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lamin_cli/_get.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lamin_cli/_get.py b/lamin_cli/_get.py index 876edf6..223da4f 100644 --- a/lamin_cli/_get.py +++ b/lamin_cli/_get.py @@ -11,19 +11,16 @@ def decompose_url(url: str) -> Tuple[str, str, str]: if entity in url: break uid = url.split(f"{entity}/")[1] - instance_slug = "/".join(url.replace("https://lamin.ai/", "").split("/")[:2]) + instance_slug = "/".join(url.split("/")[3:5]) return instance_slug, entity, uid def get(entity: str, uid: str = None, key: str = None, with_env: bool = False): - if entity.startswith("https://lamin.ai"): + if entity.startswith("https://") and "lamin" in entity: url = entity instance_slug, entity, uid = decompose_url(url) elif entity not in {"artifact", "transform"}: - raise ValueError( - "entity has to be a URL starting with https://lamin.ai or 'artifact' or" - " 'transform'" - ) + raise SystemExit("Entity has to be a laminhub URL or 'artifact' or 'transform'") else: instance_slug = None From 8bf6b87b2fe9d19800aec664f729f6090d9ae9b4 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 26 Sep 2024 21:42:23 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20Add=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_get.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_get.py b/tests/test_get.py index 1724d9b..11e7fd8 100644 --- a/tests/test_get.py +++ b/tests/test_get.py @@ -3,12 +3,16 @@ def test_decompose_url(): - url = "https://lamin.ai/laminlabs/arrayloader-benchmarks/transform/1GCKs8zLtkc85zKv" # noqa - result = decompose_url(url) - instance_slug, entity, uid = result - assert instance_slug == "laminlabs/arrayloader-benchmarks" - assert entity == "transform" - assert uid == "1GCKs8zLtkc85zKv" + urls = [ + "https://lamin.ai/laminlabs/arrayloader-benchmarks/transform/1GCKs8zLtkc85zKv", # noqa + "https://lamin.company.com/laminlabs/arrayloader-benchmarks/transform/1GCKs8zLtkc85zKv", # noqa + ] + for url in urls: + result = decompose_url(url) + instance_slug, entity, uid = result + assert instance_slug == "laminlabs/arrayloader-benchmarks" + assert entity == "transform" + assert uid == "1GCKs8zLtkc85zKv" def test_get_transform():