Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/workflows/charts_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test Python SDK

on:
workflow_call:

permissions:
contents: read

jobs:
publish:
defaults:
run:
working-directory: ./chart_data_extractor
name: Build and test Chart Data Extractor
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install dependencies
run: poetry install

- name: Test build
run: poetry build

- name: Run tests
run: poetry run pytest --verbose -x
11 changes: 11 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
outputs:
python: ${{ steps.filter.outputs.python }}
js: ${{ steps.filter.outputs.js }}
charts: ${{ steps.filter.outputs.charts }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -38,6 +39,8 @@ jobs:
- 'python/**'
js:
- 'js/**'
charts:
- 'chart_data_extractor/**'

python-tests:
needs: [ changes ]
Expand All @@ -52,3 +55,11 @@ jobs:
if: needs.changes.outputs.js == 'true'
uses: ./.github/workflows/js_tests.yml
secrets: inherit

charts-tests:
needs: [ changes ]
name: Tests Chart package
# If the PR does not have the label 'js-rc', the code is already tested in the prerelease workflow
if: needs.changes.outputs.charts == 'true' && !contains( github.event.pull_request.labels.*.name, 'charts-rc')
uses: ./.github/workflows/charts_tests.yml
secrets: inherit
136 changes: 129 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
outputs:
js: ${{ steps.filter.outputs.js }}
python: ${{ steps.filter.outputs.python }}
charts: ${{ steps.filter.outputs.charts }}
template: ${{ steps.filter.outputs.template }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -79,27 +81,147 @@ jobs:
base: ${{ steps.last_release.outputs.tag_name }}
filters: |
js:
- 'js/**'
- 'js/src/**'
python:
- 'python/**'
- 'python/e2b_code_interpreter/**'
charts:
- 'chart_data_extractor/e2b_charts/**'
template:
- 'template/**'

charts-tests:
name: Charts tests
needs: [changes]
if: needs.changes.outputs.charts == 'true'
uses: ./.github/workflows/charts_tests.yml

charts-release:
name: Charts release
needs: [charts-tests]
if: needs.changes.outputs.charts == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Create new versions
run: pnpm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release new versions
run: |
poetry build
poetry config pypi-token.pypi ${PYPI_TOKEN}
poetry publish --skip-existing
working-directory: ./chart_data_extractor
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.CHARTS_PYPI_TOKEN }}


build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [changes, charts-release]
if: needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push to DockerHub
working-directory: ./template
run: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest || true
docker buildx build \
--file Dockerfile \
--platform linux/amd64 \
--push \
--tag ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest .

build-template:
name: Build E2B template
runs-on: ubuntu-latest
needs: [build-docker-image]
if: needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install E2B CLI
run: npm install -g @e2b/cli

- name: Build e2b
run: e2b template build
working-directory: ./template
env:
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}

python-tests:
name: Python Tests
needs: [changes]
if: needs.changes.outputs.python == 'true'
needs: [changes, build-template]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.python == 'true' || needs.changes.outputs.template == 'true')
uses: ./.github/workflows/python_tests.yml
secrets: inherit

js-tests:
name: JS Tests
needs: [changes]
if: needs.changes.outputs.js == 'true'
needs: [changes, build-template]
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.js == 'true' || needs.changes.outputs.template == 'true')
uses: ./.github/workflows/js_tests.yml
secrets: inherit

release:
needs: [python-tests, js-tests]
if: (!cancelled()) && !contains(needs.*.result, 'failure') && needs.is_release.outputs.release == 'true'
if: always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.changes.outputs.js == 'true' || needs.changes.outputs.python == 'true')
name: Release
runs-on: ubuntu-latest
steps:
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/template.yml

This file was deleted.

3 changes: 3 additions & 0 deletions chart_data_extractor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Extracting Data for Code Interpreter SDK

This package is a utility used to extract data in the Code Interpreter SDK from, e.g., DataFrames and matplotlib plots.
1 change: 1 addition & 0 deletions chart_data_extractor/e2b_charts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .main import graph_figure_to_graph
4 changes: 4 additions & 0 deletions chart_data_extractor/e2b_charts/graphs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .base import GraphType, Graph
from .bars import BarGraph, BoxAndWhiskerGraph
from .pie import PieGraph
from .planar import ScatterGraph, LineGraph
Loading
Loading