From fc00a2fc8818d14c54316076b9f7979c749fa0ec Mon Sep 17 00:00:00 2001 From: gilesb Date: Wed, 7 Jan 2026 12:57:24 +0000 Subject: [PATCH] feat: add upload and publish commands --- artdag.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/artdag.py b/artdag.py index 262c67f..c6d522c 100755 --- a/artdag.py +++ b/artdag.py @@ -214,12 +214,25 @@ def view(content_hash, output): @cli.command("import") @click.argument("filepath", type=click.Path(exists=True)) def import_file(filepath): - """Import a local file to cache.""" + """Import a local file to cache (local server only).""" path = str(Path(filepath).resolve()) result = api_post("/cache/import", params={"path": path}) click.echo(f"Imported: {result['content_hash']}") +@cli.command() +@click.argument("filepath", type=click.Path(exists=True)) +def upload(filepath): + """Upload a file to cache (works with remote servers).""" + with open(filepath, "rb") as f: + files = {"file": (Path(filepath).name, f)} + resp = requests.post(f"{get_server()}/cache/upload", files=files) + resp.raise_for_status() + result = resp.json() + click.echo(f"Uploaded: {result['content_hash']}") + click.echo(f"Size: {result['size']} bytes") + + @cli.command() def assets(): """List known assets.""" @@ -229,5 +242,30 @@ def assets(): click.echo(f" {name}: {hash[:16]}...") +@cli.command() +@click.argument("run_id") +@click.argument("output_name") +@click.option("--l2", envvar="ARTDAG_L2", default="http://localhost:8200", + help="L2 server URL") +def publish(run_id, output_name, l2): + """Publish an L1 run to L2 (register ownership). + + RUN_ID: The L1 run ID to publish + OUTPUT_NAME: Name for the registered asset + """ + # Post to L2 server + resp = requests.post( + f"{l2}/registry/record-run", + json={"run_id": run_id, "output_name": output_name} + ) + resp.raise_for_status() + result = resp.json() + + click.echo(f"Published to L2!") + click.echo(f"Asset: {result['asset']['name']}") + click.echo(f"Hash: {result['asset']['content_hash']}") + click.echo(f"Activity: {result['activity']['activity_id']}") + + if __name__ == "__main__": cli()