-
Notifications
You must be signed in to change notification settings - Fork 10
Download capabilities and docker image #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e124b51
feat: download of artifact versions and vault files
Integer-Ctrl f28943e
feat: less cli args needed, downloading over databus redirect for acc…
Integer-Ctrl 62026e5
feat: dynamic local-dir creation if not specified, like databus hiera…
Integer-Ctrl f706563
feat: Dockerfile
Integer-Ctrl 8eead89
fix: moved from typer to click to enable passing args to docker image
Integer-Ctrl 2cd0d29
feat: download of artifact without version (uses lates) and group (al…
Integer-Ctrl 9e0776a
chores: clean up
Integer-Ctrl 9806d04
fix: coderabbitai
Integer-Ctrl faf7f65
fix: continue download on 404
Integer-Ctrl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| FROM python:3.10-slim | ||
|
|
||
| WORKDIR /data | ||
|
|
||
| COPY . . | ||
|
|
||
| # Install dependencies | ||
| RUN pip install . | ||
|
|
||
| # Use ENTRYPOINT for the CLI | ||
| ENTRYPOINT ["databusclient"] |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,43 +1,61 @@ | ||
| #!/usr/bin/env python3 | ||
| import typer | ||
| import click | ||
| from typing import List | ||
| from databusclient import client | ||
|
|
||
| app = typer.Typer() | ||
|
|
||
| @click.group() | ||
| def app(): | ||
| """Databus Client CLI""" | ||
| pass | ||
|
|
||
|
|
||
| @app.command() | ||
| def deploy( | ||
| version_id: str = typer.Option( | ||
| ..., | ||
| help="target databus version/dataset identifier of the form " | ||
| "<https://databus.dbpedia.org/$ACCOUNT/$GROUP/$ARTIFACT/$VERSION>", | ||
| ), | ||
| title: str = typer.Option(..., help="dataset title"), | ||
| abstract: str = typer.Option(..., help="dataset abstract max 200 chars"), | ||
| description: str = typer.Option(..., help="dataset description"), | ||
| license_uri: str = typer.Option(..., help="license (see dalicc.net)"), | ||
| apikey: str = typer.Option(..., help="apikey"), | ||
| distributions: List[str] = typer.Argument( | ||
| ..., | ||
| help="distributions in the form of List[URL|CV|fileext|compression|sha256sum:contentlength] where URL is the " | ||
| "download URL and CV the " | ||
| "key=value pairs (_ separated) content variants of a distribution. filext and compression are optional " | ||
| "and if left out inferred from the path. If the sha256sum:contentlength part is left out it will be " | ||
| "calcuted by downloading the file.", | ||
| ), | ||
| ): | ||
| typer.echo(version_id) | ||
| dataid = client.create_dataset( | ||
| version_id, title, abstract, description, license_uri, distributions | ||
| ) | ||
| @click.option( | ||
| "--version-id", "version_id", | ||
| required=True, | ||
| help="Target databus version/dataset identifier of the form " | ||
| "<https://databus.dbpedia.org/$ACCOUNT/$GROUP/$ARTIFACT/$VERSION>", | ||
| ) | ||
| @click.option("--title", required=True, help="Dataset title") | ||
| @click.option("--abstract", required=True, help="Dataset abstract max 200 chars") | ||
| @click.option("--description", required=True, help="Dataset description") | ||
| @click.option("--license", "license_url", required=True, help="License (see dalicc.net)") | ||
| @click.option("--apikey", required=True, help="API key") | ||
| @click.argument( | ||
| "distributions", | ||
| nargs=-1, | ||
| required=True, | ||
| ) | ||
| def deploy(version_id, title, abstract, description, license_url, apikey, distributions: List[str]): | ||
| """ | ||
| Deploy a dataset version with the provided metadata and distributions. | ||
| """ | ||
| click.echo(f"Deploying dataset version: {version_id}") | ||
| dataid = client.create_dataset(version_id, title, abstract, description, license_url, distributions) | ||
| client.deploy(dataid=dataid, api_key=apikey) | ||
|
|
||
|
|
||
| @app.command() | ||
| def download( | ||
| localDir: str = typer.Option(..., help="local databus folder"), | ||
| databus: str = typer.Option(..., help="databus URL"), | ||
| databusuris: List[str] = typer.Argument(...,help="any kind of these: databus identifier, databus collection identifier, query file") | ||
| ): | ||
| client.download(localDir=localDir,endpoint=databus,databusURIs=databusuris) | ||
| @click.argument("databusuris", nargs=-1, required=True) | ||
| @click.option("--localdir", help="Local databus folder (if not given, databus folder structure is created in current working directory)") | ||
| @click.option("--databus", help="Databus URL (if not given, inferred from databusuri, e.g. https://databus.dbpedia.org/sparql)") | ||
| @click.option("--token", help="Path to Vault refresh token file") | ||
| @click.option("--authurl", default="https://auth.dbpedia.org/realms/dbpedia/protocol/openid-connect/token", show_default=True, help="Keycloak token endpoint URL") | ||
| @click.option("--clientid", default="vault-token-exchange", show_default=True, help="Client ID for token exchange") | ||
| def download(databusuris: List[str], localdir, databus, token, authurl, clientid): | ||
| """ | ||
| Download datasets from databus, optionally using vault access if vault options are provided. | ||
| """ | ||
| client.download( | ||
| localDir=localdir, | ||
| endpoint=databus, | ||
| databusURIs=databusuris, | ||
| token=token, | ||
| auth_url=authurl, | ||
| client_id=clientid, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| app() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.