|
| 1 | +S3-Compatible Artifact Store |
| 2 | +============================ |
| 3 | + |
| 4 | +Reports, screenshots, and screen recordings produced by a run are usually worth |
| 5 | +keeping off the runner. ``S3ArtifactStore`` uploads, downloads, lists, and |
| 6 | +deletes them against any S3-compatible bucket (AWS S3, MinIO, Cloudflare R2, …). |
| 7 | + |
| 8 | +``boto3`` is an **optional** dependency (``pip install je_auto_control[s3]``): |
| 9 | +the S3 client is *injectable*, so the store's logic is fully unit-testable with a |
| 10 | +fake client and ``boto3`` is imported only when no client is supplied. The whole |
| 11 | +API is relative to the store's configured ``prefix`` — ``upload`` returns a |
| 12 | +store-relative key that ``download`` / ``delete`` / ``url`` accept unchanged, and |
| 13 | +``list`` strips the prefix back off. Imports no ``PySide6``. |
| 14 | + |
| 15 | +Headless API |
| 16 | +------------ |
| 17 | + |
| 18 | +.. code-block:: python |
| 19 | +
|
| 20 | + from je_auto_control import S3ArtifactStore |
| 21 | +
|
| 22 | + store = S3ArtifactStore("my-bucket", prefix="runs/42") # boto3 client lazily built |
| 23 | + key = store.upload("report.html") # -> "report.html" (relative) |
| 24 | + store.url(key) # -> "s3://my-bucket/runs/42/report.html" |
| 25 | + store.download(key, "local/report.html") |
| 26 | + store.list() # -> ["report.html", ...] |
| 27 | + store.delete(key) |
| 28 | +
|
| 29 | +For tests or non-AWS backends, pass your own client: |
| 30 | +``S3ArtifactStore("bucket", client=my_client)``. |
| 31 | + |
| 32 | +.. note:: |
| 33 | + |
| 34 | + The live AWS path requires ``boto3`` plus credentials and is therefore not |
| 35 | + exercised in CI; the store's logic is validated against a fake S3 client. |
| 36 | + |
| 37 | +Executor commands |
| 38 | +----------------- |
| 39 | + |
| 40 | +A module-level default store — configured once with |
| 41 | +``configure_default_store(bucket, client=None, prefix="")`` — backs the |
| 42 | +executor/MCP commands: |
| 43 | + |
| 44 | +================================ =================================================== |
| 45 | +Command Effect |
| 46 | +================================ =================================================== |
| 47 | +``AC_s3_upload`` Upload a local artifact; returns ``{key}``. |
| 48 | +``AC_s3_download`` Download an object to a local path. |
| 49 | +``AC_s3_list`` List object keys (optional extra ``prefix``). |
| 50 | +``AC_s3_delete`` Delete an object. |
| 51 | +================================ =================================================== |
| 52 | + |
| 53 | +The same operations are exposed as MCP tools (``ac_s3_upload`` / |
| 54 | +``ac_s3_download`` / ``ac_s3_list`` / ``ac_s3_delete``) and as Script Builder |
| 55 | +commands under **Tools**. |
0 commit comments