Skip to content

Commit 76d4ebe

Browse files
authored
Merge pull request #43 from e2b-dev/beta-split-package
Separate chart data extraction from template
2 parents ddf7f28 + bf56bef commit 76d4ebe

33 files changed

+2124
-528
lines changed

.github/workflows/charts_tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test Python SDK
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
publish:
11+
defaults:
12+
run:
13+
working-directory: ./chart_data_extractor
14+
name: Build and test Chart Data Extractor
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install and configure Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
version: 1.5.1
29+
virtualenvs-create: true
30+
virtualenvs-in-project: true
31+
installer-parallel: true
32+
33+
- name: Install dependencies
34+
run: poetry install
35+
36+
- name: Test build
37+
run: poetry build
38+
39+
- name: Run tests
40+
run: poetry run pytest --verbose -x

.github/workflows/pr.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
outputs:
1313
python: ${{ steps.filter.outputs.python }}
1414
js: ${{ steps.filter.outputs.js }}
15+
charts: ${{ steps.filter.outputs.charts }}
1516
steps:
1617
- name: Checkout repository
1718
uses: actions/checkout@v3
@@ -38,6 +39,8 @@ jobs:
3839
- 'python/**'
3940
js:
4041
- 'js/**'
42+
charts:
43+
- 'chart_data_extractor/**'
4144
4245
python-tests:
4346
needs: [ changes ]
@@ -52,3 +55,11 @@ jobs:
5255
if: needs.changes.outputs.js == 'true'
5356
uses: ./.github/workflows/js_tests.yml
5457
secrets: inherit
58+
59+
charts-tests:
60+
needs: [ changes ]
61+
name: Tests Chart package
62+
# If the PR does not have the label 'js-rc', the code is already tested in the prerelease workflow
63+
if: needs.changes.outputs.charts == 'true' && !contains( github.event.pull_request.labels.*.name, 'charts-rc')
64+
uses: ./.github/workflows/charts_tests.yml
65+
secrets: inherit

.github/workflows/release.yml

Lines changed: 129 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
outputs:
5757
js: ${{ steps.filter.outputs.js }}
5858
python: ${{ steps.filter.outputs.python }}
59+
charts: ${{ steps.filter.outputs.charts }}
60+
template: ${{ steps.filter.outputs.template }}
5961
steps:
6062
- name: Checkout repository
6163
uses: actions/checkout@v3
@@ -79,27 +81,147 @@ jobs:
7981
base: ${{ steps.last_release.outputs.tag_name }}
8082
filters: |
8183
js:
82-
- 'js/**'
84+
- 'js/src/**'
8385
python:
84-
- 'python/**'
86+
- 'python/e2b_code_interpreter/**'
87+
charts:
88+
- 'chart_data_extractor/e2b_charts/**'
89+
template:
90+
- 'template/**'
91+
92+
charts-tests:
93+
name: Charts tests
94+
needs: [changes]
95+
if: needs.changes.outputs.charts == 'true'
96+
uses: ./.github/workflows/charts_tests.yml
97+
98+
charts-release:
99+
name: Charts release
100+
needs: [charts-tests]
101+
if: needs.changes.outputs.charts == 'true'
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Checkout Repo
105+
uses: actions/checkout@v3
106+
107+
- name: Install pnpm
108+
uses: pnpm/action-setup@v3
109+
id: pnpm-install
110+
with:
111+
version: 9.5
112+
113+
- name: Set up Python
114+
uses: actions/setup-python@v4
115+
with:
116+
python-version: '3.10'
117+
118+
- name: Install and configure Poetry
119+
uses: snok/install-poetry@v1
120+
with:
121+
version: 1.5.1
122+
virtualenvs-create: true
123+
virtualenvs-in-project: true
124+
installer-parallel: true
125+
126+
- name: Configure pnpm
127+
run: |
128+
pnpm config set auto-install-peers true
129+
pnpm config set exclude-links-from-lockfile true
130+
131+
- name: Install dependencies
132+
run: pnpm install --frozen-lockfile
133+
134+
- name: Create new versions
135+
run: pnpm run version
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
139+
- name: Release new versions
140+
run: |
141+
poetry build
142+
poetry config pypi-token.pypi ${PYPI_TOKEN}
143+
poetry publish --skip-existing
144+
working-directory: ./chart_data_extractor
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
PYPI_TOKEN: ${{ secrets.CHARTS_PYPI_TOKEN }}
148+
149+
150+
build-docker-image:
151+
name: Build Docker Image
152+
runs-on: ubuntu-latest
153+
needs: [changes, charts-release]
154+
if: needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true'
155+
steps:
156+
- name: Checkout repository
157+
uses: actions/checkout@v3
158+
with:
159+
fetch-depth: 0
160+
161+
- name: Set up Docker Buildx
162+
uses: docker/setup-buildx-action@v3
163+
164+
- name: Log in to DockerHub
165+
uses: docker/login-action@v3
166+
with:
167+
username: ${{ secrets.DOCKERHUB_USERNAME }}
168+
password: ${{ secrets.DOCKERHUB_TOKEN }}
169+
170+
- name: Build and push to DockerHub
171+
working-directory: ./template
172+
run: |
173+
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest || true
174+
docker buildx build \
175+
--file Dockerfile \
176+
--platform linux/amd64 \
177+
--push \
178+
--tag ${{ secrets.DOCKERHUB_USERNAME }}/code-interpreter:latest .
179+
180+
build-template:
181+
name: Build E2B template
182+
runs-on: ubuntu-latest
183+
needs: [build-docker-image]
184+
if: needs.changes.outputs.template == 'true' || needs.changes.outputs.charts == 'true'
185+
steps:
186+
- name: Checkout repository
187+
uses: actions/checkout@v3
188+
with:
189+
fetch-depth: 0
190+
- name: Install E2B CLI
191+
run: npm install -g @e2b/cli
192+
193+
- name: Build e2b
194+
run: e2b template build
195+
working-directory: ./template
196+
env:
197+
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}
85198

86199
python-tests:
87200
name: Python Tests
88-
needs: [changes]
89-
if: needs.changes.outputs.python == 'true'
201+
needs: [changes, build-template]
202+
if: always() &&
203+
!contains(needs.*.result, 'failure') &&
204+
!contains(needs.*.result, 'cancelled') &&
205+
(needs.changes.outputs.python == 'true' || needs.changes.outputs.template == 'true')
90206
uses: ./.github/workflows/python_tests.yml
91207
secrets: inherit
92208

93209
js-tests:
94210
name: JS Tests
95-
needs: [changes]
96-
if: needs.changes.outputs.js == 'true'
211+
needs: [changes, build-template]
212+
if: always() &&
213+
!contains(needs.*.result, 'failure') &&
214+
!contains(needs.*.result, 'cancelled') &&
215+
(needs.changes.outputs.js == 'true' || needs.changes.outputs.template == 'true')
97216
uses: ./.github/workflows/js_tests.yml
98217
secrets: inherit
99218

100219
release:
101220
needs: [python-tests, js-tests]
102-
if: (!cancelled()) && !contains(needs.*.result, 'failure') && needs.is_release.outputs.release == 'true'
221+
if: always() &&
222+
!contains(needs.*.result, 'failure') &&
223+
!contains(needs.*.result, 'cancelled') &&
224+
(needs.changes.outputs.js == 'true' || needs.changes.outputs.python == 'true')
103225
name: Release
104226
runs-on: ubuntu-latest
105227
steps:

.github/workflows/template.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

chart_data_extractor/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Extracting Data for Code Interpreter SDK
2+
3+
This package is a utility used to extract data in the Code Interpreter SDK from, e.g., DataFrames and matplotlib plots.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .main import graph_figure_to_graph
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .base import GraphType, Graph
2+
from .bars import BarGraph, BoxAndWhiskerGraph
3+
from .pie import PieGraph
4+
from .planar import ScatterGraph, LineGraph

0 commit comments

Comments
 (0)