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

✨ Enable to lamin get from non-lamin.ai domains #76

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 3 additions & 6 deletions lamin_cli/_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 10 additions & 6 deletions tests/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down