feat: add upload and publish commands
This commit is contained in:
40
artdag.py
40
artdag.py
@@ -214,12 +214,25 @@ def view(content_hash, output):
|
|||||||
@cli.command("import")
|
@cli.command("import")
|
||||||
@click.argument("filepath", type=click.Path(exists=True))
|
@click.argument("filepath", type=click.Path(exists=True))
|
||||||
def import_file(filepath):
|
def import_file(filepath):
|
||||||
"""Import a local file to cache."""
|
"""Import a local file to cache (local server only)."""
|
||||||
path = str(Path(filepath).resolve())
|
path = str(Path(filepath).resolve())
|
||||||
result = api_post("/cache/import", params={"path": path})
|
result = api_post("/cache/import", params={"path": path})
|
||||||
click.echo(f"Imported: {result['content_hash']}")
|
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()
|
@cli.command()
|
||||||
def assets():
|
def assets():
|
||||||
"""List known assets."""
|
"""List known assets."""
|
||||||
@@ -229,5 +242,30 @@ def assets():
|
|||||||
click.echo(f" {name}: {hash[:16]}...")
|
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__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
|||||||
Reference in New Issue
Block a user