-
Notifications
You must be signed in to change notification settings - Fork 16
Add CLI Filtering for CVs and Introduce --dry-run Option for Deployment #57
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,9 @@ def app(): | |
| ) | ||
| @click.option("--remote", help="rclone remote name (e.g., 'nextcloud')") | ||
| @click.option("--path", help="Remote path on Nextcloud (e.g., 'datasets/mydataset')") | ||
| @click.option( | ||
| "--dry-run", is_flag=True, help="Generate and print JSON-LD without deploying" | ||
| ) | ||
| @click.argument("distributions", nargs=-1) | ||
| def deploy( | ||
| version_id, | ||
|
|
@@ -73,6 +76,7 @@ def deploy( | |
| webdav_url, | ||
| remote, | ||
| path, | ||
| dry_run, | ||
| distributions: List[str], | ||
| ): | ||
| """ | ||
|
|
@@ -105,6 +109,12 @@ def deploy( | |
| license_url=license_url, | ||
| distributions=distributions, | ||
| ) | ||
|
|
||
| if dry_run: | ||
| click.echo("[DRY-RUN] Generated DataID JSON-LD:") | ||
| click.echo(json.dumps(dataid, indent=2)) | ||
| return | ||
|
|
||
| api_deploy.deploy(dataid=dataid, api_key=apikey) | ||
| return | ||
|
|
||
|
|
@@ -113,6 +123,21 @@ def deploy( | |
| click.echo(f"[MODE] Deploy from metadata file: {metadata_file}") | ||
| with open(metadata_file, "r") as f: | ||
| metadata = json.load(f) | ||
|
|
||
| if dry_run: | ||
| click.echo("[DRY-RUN] Would deploy from metadata file") | ||
| # We could still generate the full DataID here to show it | ||
| dataid = api_deploy.create_dataset( | ||
| version_id=version_id, | ||
| artifact_version_title=title, | ||
| artifact_version_abstract=abstract, | ||
| artifact_version_description=description, | ||
| license_url=license_url, | ||
| distributions=api_deploy._create_distributions_from_metadata(metadata), | ||
| ) | ||
| click.echo(json.dumps(dataid, indent=2)) | ||
| return | ||
|
|
||
| api_deploy.deploy_from_metadata( | ||
| metadata, version_id, title, abstract, description, license_url, apikey | ||
| ) | ||
|
|
@@ -134,7 +159,17 @@ def deploy( | |
|
|
||
| click.echo("[MODE] Upload & Deploy to DBpedia Databus via Nextcloud") | ||
| click.echo(f"→ Uploading to: {remote}:{path}") | ||
| metadata = webdav.upload_to_webdav(distributions, remote, path, webdav_url) | ||
| if dry_run: | ||
| click.echo("[DRY-RUN] Skipping WebDAV upload") | ||
| metadata = [] | ||
| else: | ||
| metadata = webdav.upload_to_webdav(distributions, remote, path, webdav_url) | ||
|
|
||
| if dry_run: | ||
| click.echo("[DRY-RUN] Generated metadata (partial):") | ||
| click.echo(json.dumps(metadata, indent=2)) | ||
| return | ||
|
Comment on lines
+162
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This branch returns after printing 🤖 Prompt for AI Agents |
||
|
|
||
| api_deploy.deploy_from_metadata( | ||
| metadata, version_id, title, abstract, description, license_url, apikey | ||
| ) | ||
|
|
@@ -254,5 +289,19 @@ def delete(databusuris: List[str], databus_key: str, dry_run: bool, force: bool) | |
| ) | ||
|
|
||
|
|
||
| @app.command() | ||
| @click.argument("shell", type=click.Choice(["bash", "zsh", "fish"])) | ||
| def completion(shell): | ||
| """Generate shell completion script.""" | ||
| import os | ||
|
|
||
| if shell == "bash": | ||
| os.system("_DATABUSCLIENT_COMPLETE=bash_source databusclient") | ||
| elif shell == "zsh": | ||
| os.system("_DATABUSCLIENT_COMPLETE=zsh_source databusclient") | ||
| elif shell == "fish": | ||
| os.system("_DATABUSCLIENT_COMPLETE=fish_source databusclient") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| app() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fall back to the file name when
formatExtensionorcompressionis missing.file_formatandcompressionare optional in published metadata, so.ttl/..gzcurrently fail on otherwise validPartnodes that only exposefile. That makes the new filter syntax silently skip matching files on those datasets.💡 Localized fix
for f in filters: if f.startswith(".."): # Compression filter expected = f[2:].lower() - actual = str(node.get("compression", "")).lower() + actual = str(node.get("compression", "")).lower() + if not actual: + actual = _detect_compression_format(str(node.get("file", ""))) or "" if actual != expected: return False elif f.startswith("."): # Format extension filter expected = f[1:].lower() - actual = str(node.get("formatExtension", "")).lower() + actual = str(node.get("formatExtension", "")).lower() + if not actual: + path = urlparse(str(node.get("file", ""))).path + basename = os.path.basename(path).lower() + basename = re.sub(r"\.(bz2|gz|xz)$", "", basename) + actual = basename.rsplit(".", 1)[-1] if "." in basename else "" if actual != expected: return False🤖 Prompt for AI Agents