Metadata-Version: 2.4
Name: artifact-secretary
Version: 0.0.13
Summary: Agentic discovery of compiled HPC applications: characterize an artifact's arch, linkage, capability, and provenance so a scheduler knows where it can run.
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: pyelftools>=0.30
Requires-Dist: anyio>=4
Requires-Dist: behalf>=0.1
Provides-Extra: claude
Requires-Dist: behalf[claude]>=0.1; extra == "claude"
Provides-Extra: gemini
Requires-Dist: behalf[gemini]>=0.1; extra == "gemini"
Provides-Extra: aws
Requires-Dist: behalf[aws]>=0.1; extra == "aws"
Provides-Extra: all
Requires-Dist: behalf[all]>=0.1; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Dynamic: license-file

# artifact-secretary

[![DOI](https://zenodo.org/badge/1307057776.svg)](https://doi.org/10.5281/zenodo.21746007)

![https://github.com/converged-computing/artifact-secretary/blob/main/img/artifact-secretary-small.png](https://github.com/converged-computing/artifact-secretary/blob/main/img/artifact-secretary-small.png)

[![PyPI - Version](https://img.shields.io/pypi/v/artifact-secretary)](https://badge.fury.io/py/artifact-secretary)


This library serves as a discovery tool to look into opaque objects (like containers) to figure out what is needed to run, build, etc. Our use case is for scheduling. We want to find the best spot for said opaque container.


## Details

### Container Discovery

For each image in a catalog:

1. Start the container running.
2. Copy our inspection code (Python) into it.
3. An agent drives the inspection (find binary, read ELF and linkage, how compiled).
4. Writes results into an artifact.


## Install

Use the devcontainer (`.devcontainer/`).

```bash
python3 -m pip install -e .
python3 -m pip install -e .[aws]

# Claude
export ANTHROPIC_API_KEY=sk-ant-...

# AWS
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=us-east-1

# OR
export AWS_BEARER_TOKEN_BEDROCK=...
```

Test connection:

```bash
aws sts get-caller-identity
aws bedrock list-inference-profiles --region "$AWS_DEFAULT_REGION" \
  --query 'inferenceProfileSummaries[].inferenceProfileId' --output text
```
```bash
python3 -c "import boto3; print(boto3.client('sts').get_caller_identity()['Arn'])"
python3 -c "import boto3,os; c=boto3.client('bedrock', region_name=os.environ.get('AWS_DEFAULT_REGION','us-east-1')); print([p['inferenceProfileId'] for p in c.list_inference_profiles()['inferenceProfileSummaries']])"
```

And test:

```bash
python3 - <<'PY'
from strands import Agent
from strands.models import BedrockModel
m = BedrockModel(model_id="us.anthropic.claude-sonnet-5",  # paste a real one from step 3
                 region_name="us-east-1")
print(Agent(model=m)("say ok"))
PY
```

## Usage

### Container Profile

Here is a one-off example:

```bash
artifact-secretary profile --backend aws \
  --model us.anthropic.claude-sonnet-5 \
  --catalog ghcr.io/converged-computing/metric-lammps-cpu:zen4-reax \
  --out lookup.json --keep-images
```

By default it deletes any image it had to pull so your disk doesn't fill up.
Images you already had are left alone. Use `--keep-images` to keep everything.

The inspection library works on its own if you just want the facts and don't
want an agent or a key:

```python
from secretary import Target, Inspector, derive_capability
insp = Inspector(Target("/opt/lammps"))
elf = insp.inspect_elf("/build/lmp")
cap = derive_capability(elf["needed"], elf["rpath"])
```

Here is how to use the artifact secretary to list packages and tags from GitHub packages:

```bash
export GITHUB_TOKEN=...   # needs read:packages
artifact-secretary list --org converged-computing --repo performance-study
```

And then derive each one:

```bash
for repo in $(cat repos.txt)
  do
    artifact-secretary profile --backend aws --model us.anthropic.claude-opus-5 \
      --catalog "$repo" --out-dir manifests --allow-network
done
```

### Source Code Profile

```bash
# default execution is container.
artifact-secretary shape --backend aws --model us.anthropic.claude-sonnet-5 \
  --repos https://github.com/lammps/lammps --focus reaxff \
  --max-source-tokens 60000 --model-max-tokens 16384 --out shapes.json
```

## License

HPCIC DevTools is distributed under the terms of the MIT license.
All new contributions must be made under this license.

See [LICENSE](https://github.com/converged-computing/cloud-select/blob/main/LICENSE),
[COPYRIGHT](https://github.com/converged-computing/cloud-select/blob/main/COPYRIGHT), and
[NOTICE](https://github.com/converged-computing/cloud-select/blob/main/NOTICE) for details.

SPDX-License-Identifier: (MIT)

LLNL-CODE- 842614
