Metadata-Version: 2.5
Name: canfar-lab
Version: 0.7.0
Summary: In-session workbench and workload CLI extensions for the CANFAR Science Platform
Project-URL: Homepage, https://github.com/astroai/canfar-lab
Project-URL: Documentation, https://github.com/astroai/canfar-lab/blob/main/docs/USAGE.md
Project-URL: Repository, https://github.com/astroai/canfar-lab
Project-URL: Issues, https://github.com/astroai/canfar-lab/issues
Project-URL: Platform, https://opencadc.github.io/canfar/
Author-email: Simon Fabbro <simon.fabbro@nrc-cnrc.gc.ca>
License: MIT License
        
        Copyright (c) 2026 Sébastien Fabbro
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: astroai,astronomy,canfar,science-platform,session
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.10
Requires-Dist: canfar>=1.5.2
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic-settings>=2.16.1
Requires-Dist: pydantic>=2.14.1
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: rich>=15.0.0
Requires-Dist: tomli>=2.5.0; python_version < '3.11'
Requires-Dist: typer>=0.27.3
Provides-Extra: dev
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
Requires-Dist: pytest>=9.1.1; extra == 'dev'
Requires-Dist: ruff>=0.17.2; extra == 'dev'
Requires-Dist: ty>=0.0.91; extra == 'dev'
Description-Content-Type: text/markdown

# canfar-lab

The **`canfar lab`** commands you run *inside* an AstroAI session on the
[CANFAR Science Platform](https://www.opencadc.org/canfar/). The same tree is
the standalone `canfar-lab` binary.

Start and stop sessions with [`canfar`](https://github.com/opencadc/canfar)
(or the Science Portal). Inside the session, `canfar lab` does three jobs:

1. **Project env** — `init` / `clone` / `save` / `resume` (lockfiles on `/arc`)
2. **Ray cluster** — `cluster start` / `status` / `run` / `jobs`
3. **Agents** — `agent setup` / `install` / `verify`

```mermaid
flowchart LR
  subgraph laptop [Laptop or portal]
    Portal[Science Portal]
    CanfarCLI["canfar login / create"]
  end
  subgraph session [AstroAI session]
    Lab["canfar lab"]
    Tools["pixi / uv / Jupyter / CADC / Ray"]
  end
  Portal --> session
  CanfarCLI --> session
  Lab --> Tools
```

| Name | Meaning |
|------|---------|
| **AstroAI** | Product: GitHub [`astroai`](https://github.com/astroai), Harbor `astroai` |
| **CANFAR** | Host platform: portal, Skaha, `/arc`, auth |
| **`canfar`** | Platform CLI — sessions and `canfar data` |
| **`canfar lab` / `canfar-lab`** | This package, inside a session |
| **`images.canfar.net/astroai/*`** | Session images |

Images: [canfar-containers](https://github.com/astroai/canfar-containers).

## Inside a session

```bash
canfar lab                      # status banner
canfar lab init mylab           # or: clone owner/repo
canfar lab save                    # lockfile snapshot to /arc
canfar lab resume mylab
canfar lab status                  # quotas, sessions (not the Ray cluster)

canfar lab cluster start
canfar lab cluster status
canfar lab run train.py --cpus 2

canfar lab kernel ensure
canfar lab agent setup
```

`canfar lab status` is this session’s CPU/disk/quota. `canfar lab cluster status`
is whether the Ray cluster is up. `canfar lab cluster stop` tears down workers
and the manager.

Help: `canfar lab help` · one command: `canfar lab help -c cluster` · cheat sheet:
[docs/help.md](docs/help.md)

## Install

```bash
pip install canfar-lab
canfar-lab --help
```

Do not pass `--user`. On a CANFAR session that writes `/arc/home/.local`. If the image Python is not writable, `uv pip install --python /opt/canfar canfar-lab`. Upgrade with `pip install -U canfar-lab`. Session images that already include the package put `canfar-lab` on PATH.

## Docs

| Doc | What it is |
|-----|------------|
| [docs/help.md](docs/help.md) | Cheat sheet |
| [docs/USAGE.md](docs/USAGE.md) | Storage, workflows, Ray, agents |
| [docs/cli.md](docs/cli.md) | Flags and every command |
| [docs/config.md](docs/config.md) | Optional `~/.astroai/lab/config.yaml` |
| [docs/concurrency.md](docs/concurrency.md) | Shared home: locks, atomic writes, agent runtime placement |
| [docs/studio.md](docs/studio.md) | AstroAI Studio: the browser coding portal, its dsh profile, teams, storage split |
| [docs/desk-sync.md](docs/desk-sync.md) | Desk cockpit and CANFAR ↔ desktop sync (design proposal) |
| [docs/panel.md](docs/panel.md) | AstroAI Panel / Studio Team review (keys only; models in dsh Settings) |

Data movement is not this CLI. Use **`canfar data`** and `vcp` / `vls`.

## Development

```bash
./scripts/ci.sh
pixi run test
```

[MIT](LICENSE). `canfar` keeps its own license.
