Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb4a0cf
Go back to skipping the bump-versions step of the GHA
snwessel Nov 4, 2024
64c9189
Merge branch 'master' into remove-autogen-bb-client
snwessel Nov 4, 2024
b982e02
Reapply "refactor(breadbox): Remove auto-generated client" (#118)
snwessel Nov 4, 2024
4ef57a7
Go back to skipping github actions version bump
snwessel Nov 4, 2024
26c33cc
Add back export-api-spec step
snwessel Nov 4, 2024
91c29bc
Add step to install bb dependencies before autogen
snwessel Nov 4, 2024
b5bd00a
Fix directory issues
snwessel Nov 4, 2024
3b22453
Fix poetry env activation issue
snwessel Nov 4, 2024
deaf94e
Fix export api path
snwessel Nov 4, 2024
e272543
Try defining generation steps as separate action
snwessel Nov 4, 2024
464a6cf
Set default shell to bash
snwessel Nov 4, 2024
3543289
Set shell without using defaults
snwessel Nov 4, 2024
6051cc6
Set mandatory "using" param
snwessel Nov 4, 2024
500d637
Use reusable action in publish step as well
snwessel Nov 4, 2024
c0268b9
Update breadbox-client README with new instructions
snwessel Nov 4, 2024
da81b33
Uncomment portal build step
snwessel Nov 4, 2024
e7a02a6
Rename publish client step
snwessel Nov 5, 2024
c90da57
Merge branch 'master' into remove-autogen-bb-client
snwessel Nov 7, 2024
034f328
Add back client generator, remove api spec
snwessel Nov 7, 2024
2a72bcc
Update client local development instructions
snwessel Nov 7, 2024
680c567
Merge branch 'master' into remove-autogen-bb-client
snwessel Nov 19, 2024
5565aa1
Debug poetry virtual envs in GHA
snwessel Nov 19, 2024
ccc0664
Merge branch 'master' into bb-client-autogen-debugging
snwessel Nov 19, 2024
7df5794
Try installing breadbox-client-generator as well
snwessel Nov 19, 2024
25e2a9a
Fix package mode in client generator
snwessel Nov 19, 2024
0662531
Fix poetry package issue (part 2)
snwessel Nov 19, 2024
4ce3afd
Try running existing command
snwessel Nov 19, 2024
9d7601e
testing poetry settings
pgm Nov 20, 2024
9af5710
testing poetry settings
pgm Nov 20, 2024
4487938
fixed bad yaml
pgm Nov 20, 2024
7b0b14e
Fix typo
snwessel Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/actions/generate-breadbox-client/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# A re-usable github action which generates the breadbox client
name: "generate-breadbox-client"
description: "Auto-generate the breadbox client"
runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
virtualenvs-in-project: false
- name: Install breadbox-client-generator python dependencies
working-directory: ./breadbox-client-generator
run: poetry install # Installs to /home/runner/work/depmap-portal/depmap-portal/breadbox-client-generator/.venv
shell: bash
- name: Install breadbox python dependencies
working-directory: ./breadbox
run: poetry install # Installs to /home/runner/work/depmap-portal/depmap-portal/breadbox/.venv
shell: bash
- name: print path to breadbox interpreter
working-directory: ./breadbox
run: |
poetry run which python
shell: bash
- name: print path to client generator interpreter
working-directory: ./breadbox
run: |
poetry run poetry run -C ../breadbox-client-generator which python
shell: bash
- name: Export the breadbox API spec
working-directory: ./breadbox
run: |
poetry run ./bb export-api-spec ../breadbox-client/latest-breadbox-api.json
shell: bash
- name: Generate the breadbox client
working-directory: ./breadbox
run: poetry run ./bb update-client
shell: bash
44 changes: 7 additions & 37 deletions .github/workflows/build_breadbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Generate breadbox client
uses: ./.github/actions/generate-breadbox-client # defined as a re-usable action
- name: check that the breadbox client passes pyright
working-directory: ./breadbox-client
run: |
cd breadbox-client && poetry install && poetry run pyright breadbox_facade
poetry run pyright breadbox_facade
build-docker:
runs-on: ubuntu-latest
steps:
Expand All @@ -93,9 +90,6 @@ jobs:
yarn --cwd frontend "build:elara"
- name: build docker image
run: bash breadbox/build-docker-image.sh ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
- name: check that the breadbox client is in sync with the latest API spec
run: |
docker run -v $PWD/breadbox-client/latest-breadbox-api.json:/latest-breadbox-api.json ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} poetry run ./bb check-api /latest-breadbox-api.json
- name: Run pyright-ratchet
run: |
docker run -v $PWD/breadbox/pyright-ratchet-errors.txt:/install/breadbox/pyright-ratchet-errors.txt ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} poetry run pyright-ratchet
Expand Down Expand Up @@ -186,13 +180,10 @@ jobs:
- name: Get bumped version
run: echo "${{ steps.current-version.outputs.bumped_version}}"

publish-breadbox-and-client:
publish-breadbox-client:
needs: bump-versions
if: ${{ (needs.bump-versions.outputs.current_version != needs.bump-versions.outputs.bumped_version) && (github.ref_name == 'master') }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./breadbox
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -206,29 +197,8 @@ jobs:
with:
# See instructions here: https://github.com/google-github-actions/auth?tab=readme-ov-file#service-account-key-json
credentials_json: ${{ secrets.DEPMAP_ARTIFACTS_SVC_ACCT }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Set up cache
uses: actions/cache@v2
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Set up for publishing breadbox
working-directory: ./breadbox
run: |
poetry self add keyrings.google-artifactregistry-auth
poetry config repositories.public-python https://us-central1-python.pkg.dev/cds-artifacts/public-python/
- name: Publish new breadbox version to Artifact Registry
working-directory: ./breadbox
run: poetry publish --build --repository public-python
- name: Generate breadbox client
uses: ./.github/actions/generate-breadbox-client # defined as a re-usable action
- name: Set up for publishing breadbox client
working-directory: ./breadbox-client
run: |
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,16 @@ app_datasets/
breadbox/install
breadbox/breadbox/static
breadbox/breadbox/result
# generated file

# generated files
portal-backend/depmap/utilities/color_palette.py
breadbox/app_datasets
breadbox_client/
latest-breadbox-api.json
secrets

# data access logs
portal-backend/access.log

# predictability output_data from local run
output_data/
output_data/
3 changes: 3 additions & 0 deletions breadbox-client-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Breadbox Client Generator

A poetry project used for the generation of the breadbox client. This is defined as a separate project because the `openapi-python-client` has dependency conflicts with breadbox.
2 changes: 1 addition & 1 deletion breadbox-client-generator/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion breadbox-client-generator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
package-mode = false
packages = [{include = "breadbox_client_generator"}]

[tool.poetry.dependencies]
Expand All @@ -13,4 +14,4 @@ openapi-python-client = "^0.21.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"
40 changes: 32 additions & 8 deletions breadbox-client/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
# The Breadbox Facade
# The Breadbox Client

A client library for accessing Breadbox

Includes both an auto-generated `breadbox_client` module and a human-curated `breadbox_facade` which defines a more user-friendly interface for the client.


## Auto-Generating the breadbox_client
When changes are merged to master, the `breadbox-client/breadbox_client` directory will be auto-generated before the breadbox-client module is published.

In general, the `breadbox_client` directory is auto-generated in a github action. It is not checked in to the repo.
When changes are merged to master, the `breadbox-client/breadbox_client` directory will be auto-generated before the breadbox-client module is published.

To generate the client for local development:
1. Make sure you have the `breadbox-client-generator` poetry project installed:
```
cd ../breadbox-client-generator
poetry install
```
2. Generate the breadbox client:
```
cd ../breadbox
poetry run ./bb update-client
```

A user-friendly facade for the autogenerated breadbox client.

### This includes improvements such as:
## The breadbox Facade

#### Includes improvements such as:

- **Simpler return types**. For example, the facade's get_datasets method returns `list[DatasetResponse]` instead of `Optional[Union[HTTPError, HTTPValidationError, List["DatasetResponse"]]]`
- **Better error handling**: Exceptions are raised instead of being returned
- **Constructors for custom types** For example, this facade accepts DataFrames instead of taking `breadbox_client.types.File` objects.
- **Better handling of None values** in cases where the autogenerated client wants to be given UNSET instead of None

### To publish a new version:
## To publish a new version of this module:

**Option 1 (preferred)**: Merge your changes to the main branch. This module will be automatically updated and published.

**Option 2**: Publish from local changes

To setup for publishing (Based on https://medium.com/google-cloud/python-packages-via-gcps-artifact-registry-ce1714f8e7c1 )

Expand Down Expand Up @@ -62,10 +90,6 @@ poetry source add --priority=supplemental public-python https://us-central1-pyth
poetry add --source public-python breadbox-facade
```

# breadbox-client

A client library for accessing Breadbox

## Usage

First, create a client:
Expand Down
8 changes: 0 additions & 8 deletions breadbox-client/breadbox_client/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion breadbox-client/breadbox_client/api/__init__.py

This file was deleted.

Empty file.
Loading