diff --git a/.github/workflows/cd-py-cloud.yml b/.github/workflows/cd-py-cloud.yml index bd1d283e9..6b653194b 100644 --- a/.github/workflows/cd-py-cloud.yml +++ b/.github/workflows/cd-py-cloud.yml @@ -30,18 +30,23 @@ jobs: - name: Determine version id: get-version + env: + INPUT_VERSION: ${{ inputs.version }} + EVENT_NAME: ${{ github.event_name }} + GITHUB_REF_RAW: ${{ github.ref }} + EVENT_INPUT_VERSION: ${{ github.event.inputs.version }} run: | - if [ -n "${{ inputs.version }}" ]; then - VERSION=${{ inputs.version }} - elif [ "${{ github.event_name }}" == "push" ]; then - if [[ "${{ github.ref }}" =~ ^refs/tags/cloud-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then + if [ -n "$INPUT_VERSION" ]; then + VERSION=$INPUT_VERSION + elif [ "$EVENT_NAME" == "push" ]; then + if [[ "$GITHUB_REF_RAW" =~ ^refs/tags/cloud-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then VERSION=${BASH_REMATCH[1]} else echo "Invalid tag format for cloud" exit 1 fi - elif [ -n "${{ github.event.inputs.version }}" ]; then - VERSION=${{ github.event.inputs.version }} + elif [ -n "$EVENT_INPUT_VERSION" ]; then + VERSION=$EVENT_INPUT_VERSION else echo "ERROR: No version found!" exit 1 diff --git a/.github/workflows/cd-py-train.yml b/.github/workflows/cd-py-train.yml deleted file mode 100644 index 4eedc3420..000000000 --- a/.github/workflows/cd-py-train.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: "CD: cua-train (PyPI)" - -on: - push: - tags: - - "train-v*" - workflow_dispatch: - inputs: - version: - description: "Version to publish (without v prefix)" - required: true - default: "0.1.0" - workflow_call: - inputs: - version: - description: "Version to publish" - required: true - type: string - -permissions: - contents: write - -jobs: - prepare: - runs-on: macos-latest - outputs: - version: ${{ steps.get-version.outputs.version }} - steps: - - uses: actions/checkout@v4 - - - name: Determine version - id: get-version - run: | - if [ -n "${{ inputs.version }}" ]; then - VERSION=${{ inputs.version }} - elif [ "${{ github.event_name }}" == "push" ]; then - if [[ "${{ github.ref }}" =~ ^refs/tags/train-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then - VERSION=${BASH_REMATCH[1]} - else - echo "Invalid tag format for train" - exit 1 - fi - elif [ -n "${{ github.event.inputs.version }}" ]; then - VERSION=${{ github.event.inputs.version }} - else - echo "ERROR: No version found!" - exit 1 - fi - echo "version=$VERSION" >> $GITHUB_OUTPUT - - publish: - needs: prepare - uses: ./.github/workflows/py-reusable-publish.yml - with: - package_name: "train" - package_dir: "libs/python/cua-train" - version: ${{ needs.prepare.outputs.version }} - base_package_name: "cua-train" - secrets: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - - create-release: - needs: [prepare, publish] - uses: ./.github/workflows/release-github-reusable.yml - with: - tag_name: "train-v${{ needs.prepare.outputs.version }}" - release_name: "cua-train v${{ needs.prepare.outputs.version }}" - module_path: "libs/python/cua-train" - body: "" diff --git a/.github/workflows/release-bump-version.yml b/.github/workflows/release-bump-version.yml index bf579cd01..a4a6cf74d 100644 --- a/.github/workflows/release-bump-version.yml +++ b/.github/workflows/release-bump-version.yml @@ -22,7 +22,7 @@ on: - pypi/sandbox - pypi/sandbox-apps - pypi/som - - pypi/train + - pypi/cloud - npm/cli - npm/computer - npm/core @@ -119,8 +119,8 @@ jobs: echo "directory=libs/python/som" >> $GITHUB_OUTPUT echo "type=python" >> $GITHUB_OUTPUT ;; - "pypi/train") - echo "directory=libs/python/cua-train" >> $GITHUB_OUTPUT + "pypi/cloud") + echo "directory=libs/python/cua-cloud" >> $GITHUB_OUTPUT echo "type=python" >> $GITHUB_OUTPUT ;; "npm/cli") @@ -425,13 +425,13 @@ jobs: echo "SOM version: $VERSION" echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - name: Capture bumped train version - if: ${{ inputs.service == 'pypi/train' }} - id: train_version + - name: Capture bumped cloud version + if: ${{ inputs.service == 'pypi/cloud' }} + id: cloud_version run: | - cd libs/python/cua-train + cd libs/python/cua-cloud VERSION=$(python -c "import tomllib; from pathlib import Path; data = tomllib.loads(Path('pyproject.toml').read_text()); print(data['project']['version'])") - echo "Train version: $VERSION" + echo "Cloud version: $VERSION" echo "version=$VERSION" >> "$GITHUB_OUTPUT" - name: Capture bumped npm/cli version diff --git a/libs/python/cua-cloud/.bumpversion.cfg b/libs/python/cua-cloud/.bumpversion.cfg index d0e711dc5..f2cdf6ebe 100644 --- a/libs/python/cua-cloud/.bumpversion.cfg +++ b/libs/python/cua-cloud/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.1 +current_version = 0.1.2 commit = True tag = True tag_name = cloud-v{new_version} @@ -8,7 +8,3 @@ message = Bump cua-cloud to v{new_version} [bumpversion:file:pyproject.toml] search = version = "{current_version}" replace = version = "{new_version}" - -[bumpversion:file:cua_cloud/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" diff --git a/libs/python/cua-cloud/README.md b/libs/python/cua-cloud/README.md index bedc05b26..9f040e904 100644 --- a/libs/python/cua-cloud/README.md +++ b/libs/python/cua-cloud/README.md @@ -1,14 +1,23 @@ # cua-cloud -Placeholder package for the future Cua Cloud Python SDK. - -## Installation +Python client for the [Cua Cloud](https://run.cua.ai) API. ```bash pip install cua-cloud ``` -## Status +```python +from cua_cloud import CloudClient + +client = CloudClient.from_key( + client_id="ukey-...", # from your Cua Cloud account + client_secret="...", +) -This package is intentionally empty today. It exists to reserve the package -name and provide a stable place for future Cua Cloud Python APIs. +# Control plane — claim a VM +http = client.get_async_httpx_client() +await http.post("/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/my-pool/osgymsandboxclaims", json={...}) + +# Data plane — exec in the VM +await http.post("/api/svc/my-pool/my-sandbox-server/execute", json={"command": "echo hi"}) +``` diff --git a/libs/python/cua-cloud/pyproject.toml b/libs/python/cua-cloud/pyproject.toml index 0f8d03075..ea7cd7501 100644 --- a/libs/python/cua-cloud/pyproject.toml +++ b/libs/python/cua-cloud/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "cua-cloud" -version = "0.1.1" -description = "Placeholder package for future Cua Cloud Python SDK." +version = "0.1.2" +description = "Cua Cloud Python client — control and data plane for Cua Cloud desktop VM pools" readme = "README.md" license = "MIT" authors = [ @@ -9,8 +9,10 @@ authors = [ ] keywords = [ "cua", - "cloud", "computer-use", + "cloud", + "vm", + "automation", ] classifiers = [ "Development Status :: 3 - Alpha", @@ -24,7 +26,7 @@ classifiers = [ "Topic :: Software Development :: Libraries", ] requires-python = ">=3.11,<3.14" -dependencies = [] +dependencies = ["httpx>=0.27.0"] [project.urls] Homepage = "https://github.com/trycua/cua" diff --git a/libs/python/cua-cloud/src/cua_cloud/__init__.py b/libs/python/cua-cloud/src/cua_cloud/__init__.py new file mode 100644 index 000000000..30ac337d7 --- /dev/null +++ b/libs/python/cua-cloud/src/cua_cloud/__init__.py @@ -0,0 +1,5 @@ +"""cua-cloud — Python client for the Cua Cloud API.""" + +from .client import CloudClient + +__all__ = ["CloudClient"] diff --git a/libs/python/cua-train/src/cua_train/client.py b/libs/python/cua-cloud/src/cua_cloud/client.py similarity index 97% rename from libs/python/cua-train/src/cua_train/client.py rename to libs/python/cua-cloud/src/cua_cloud/client.py index 652c883a4..101d4a8bd 100644 --- a/libs/python/cua-train/src/cua_train/client.py +++ b/libs/python/cua-cloud/src/cua_cloud/client.py @@ -1,4 +1,4 @@ -"""TrainClient — authenticated httpx client for the Cua Cloud API.""" +"""CloudClient — authenticated httpx client for the Cua Cloud API.""" from __future__ import annotations @@ -8,7 +8,7 @@ import httpx -class TrainClient: +class CloudClient: """Authenticated client for the Cua Cloud API. Obtain via :meth:`from_key` using a per-user key (``ukey-…``) from @@ -50,7 +50,7 @@ def from_key( client_id: str, client_secret: str, base_url: str = _DEFAULT_BASE_URL, - ) -> "TrainClient": + ) -> "CloudClient": """Exchange client credentials for a bearer token. Args: diff --git a/libs/python/cua-train/.bumpversion.cfg b/libs/python/cua-train/.bumpversion.cfg deleted file mode 100644 index 35f6ea62a..000000000 --- a/libs/python/cua-train/.bumpversion.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[bumpversion] -current_version = 0.1.2 -commit = True -tag = True -tag_name = train-v{new_version} -message = Bump cua-train to v{new_version} - -[bumpversion:file:pyproject.toml] -search = version = "{current_version}" -replace = version = "{new_version}" diff --git a/libs/python/cua-train/README.md b/libs/python/cua-train/README.md deleted file mode 100644 index 732cbeb0a..000000000 --- a/libs/python/cua-train/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# cua-train - -Python client for the [Cua Cloud](https://run.cua.ai) API. - -```bash -pip install cua-train -``` - -```python -from cua_train import TrainClient - -client = TrainClient.from_key( - client_id="ukey-...", # from your Cua Cloud account - client_secret="...", -) - -# Control plane — claim a VM -http = client.get_async_httpx_client() -await http.post("/api/k8s/apis/osgym.cua.ai/v1alpha1/namespaces/my-pool/osgymsandboxclaims", json={...}) - -# Data plane — exec in the VM -await http.post("/api/svc/my-pool/my-sandbox-server/execute", json={"command": "echo hi"}) -``` diff --git a/libs/python/cua-train/pyproject.toml b/libs/python/cua-train/pyproject.toml deleted file mode 100644 index bef5804d2..000000000 --- a/libs/python/cua-train/pyproject.toml +++ /dev/null @@ -1,38 +0,0 @@ -[project] -name = "cua-train" -version = "0.1.2" -description = "Cua Cloud Python client — control and data plane for Cua Cloud desktop VM pools" -readme = "README.md" -license = "MIT" -authors = [ - { name = "TryCua", email = "hello@trycua.com" } -] -keywords = [ - "cua", - "computer-use", - "cloud", - "vm", - "automation", -] -classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", -] -requires-python = ">=3.10" -dependencies = ["httpx>=0.27.0"] - -[project.urls] -Homepage = "https://run.cua.ai" -Repository = "https://github.com/trycua/cua" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.hatch.build.targets.wheel] -packages = ["src/cua_train"] diff --git a/libs/python/cua-train/src/cua_train/__init__.py b/libs/python/cua-train/src/cua_train/__init__.py deleted file mode 100644 index 480843318..000000000 --- a/libs/python/cua-train/src/cua_train/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -"""cua-train — Python client for the Cua Cloud API.""" - -from .client import TrainClient - -__all__ = ["TrainClient"]