Skip to content

Commit 8575711

Browse files
committed
[CI] Fix public repo sync workflow (#807)
1 parent e88a784 commit 8575711

File tree

19 files changed

+1358
-196
lines changed

19 files changed

+1358
-196
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ jobs:
205205
if: always() && steps.launch_services.outcome == 'success'
206206
run: |
207207
cp .env services/api/.env
208-
cd services/api
208+
pushd services/api
209209
210210
if [ "${{ matrix.test-group }}" = "group1" ]; then
211211
DIRS=(tests --ignore=tests/gen_table/test_row_ops.py --ignore=tests/gen_table/test_row_ops_v2.py --ignore=tests/routers --ignore=tests/utils)
@@ -224,6 +224,12 @@ jobs:
224224
--junitxml=pytest_regular.xml \
225225
-m "not (${{ matrix.jamai-mode == 'cloud' && 'oss' || 'cloud' }} or stripe)" \
226226
"${DIRS[@]}"
227+
228+
# Shut down owl to allow coverage data to be flushed
229+
popd
230+
docker compose -p jm -f docker/compose.ci.yml down
231+
# Copy Pytest coverage data
232+
sudo find docker_data -type f -name '.coverage.*' -exec cp -v -t services/api/coverage/. {} +
227233
env:
228234
OWL_DB_PATH: postgresql+psycopg://owlpguser:owlpgpassword@localhost:5432/jamaibase_owl
229235
OWL_CLICKHOUSE_HOST: localhost
@@ -243,10 +249,6 @@ jobs:
243249
id: test_stripe
244250
if: matrix.jamai-mode == 'cloud' && matrix.test-group == 'group1' && steps.launch_services.outcome == 'success'
245251
run: |
246-
# Shut down owl to allow coverage data to be flushed
247-
docker compose -p jm -f docker/compose.ci.yml down
248-
# Copy Pytest coverage data
249-
sudo cp -r docker_data docker_data_tmp
250252
sudo rm -rf docker_data
251253
252254
# Relaunch
@@ -274,9 +276,11 @@ jobs:
274276
-m stripe \
275277
tests
276278
277-
# Move existing coverage data
279+
# Shut down owl to allow coverage data to be flushed
278280
popd
279-
mv docker_data_tmp/owl/db/* docker_data/owl/db/. 2>/dev/null || true
281+
docker compose -p jm -f docker/compose.ci.yml down
282+
# Move existing coverage data
283+
sudo find docker_data -type f -name '.coverage.*' -exec cp -v -t services/api/coverage/. {} +
280284
env:
281285
STRIPE_API_KEY: ${{ secrets.OWL_STRIPE_API_KEY }}
282286
OWL_STRIPE_API_KEY: ${{ secrets.OWL_STRIPE_API_KEY }}
@@ -313,15 +317,6 @@ jobs:
313317
[Link to logs (${{ matrix.jamai-mode }}, ${{ matrix.test-group }})](${{ steps.upload_logs.outputs.artifact-url }})
314318
comment-tag: logs_comment_${{ matrix.jamai-mode }}-${{ matrix.test-group }}
315319

316-
- name: Upload pytest coverage file
317-
uses: actions/upload-artifact@v4
318-
if: always() && steps.python_sdk_test.outcome == 'success'
319-
with:
320-
name: pytest-coverage-data-${{ matrix.jamai-mode }}-${{ matrix.test-group }}
321-
path: services/api/coverage
322-
include-hidden-files: true
323-
if-no-files-found: error
324-
325320
- name: Merge JUnit XML and Coverage data
326321
id: merge_test_data
327322
if: always() && steps.launch_services.outcome == 'success'
@@ -331,7 +326,7 @@ jobs:
331326
332327
# Combine coverage data
333328
coverage combine --keep --data-file=services/api/coverage/.coverage --rcfile=services/api/pyproject.toml \
334-
docker_data/owl/db services/api/coverage
329+
services/api/coverage
335330
336331
# Merge JUnit XML files
337332
mkdir -p services/api/junit_xml
@@ -341,8 +336,8 @@ jobs:
341336
uses: actions/upload-artifact@v4
342337
if: always() && steps.merge_test_data.outcome == 'success'
343338
with:
344-
name: docker_data-coverage-data-${{ matrix.jamai-mode }}-${{ matrix.test-group }}
345-
path: docker_data/owl/db
339+
name: owl-coverage-${{ matrix.jamai-mode }}-${{ matrix.test-group }}
340+
path: services/api/coverage
346341
include-hidden-files: true
347342
if-no-files-found: error
348343

@@ -353,12 +348,6 @@ jobs:
353348
name: junit-xml-data-${{ matrix.jamai-mode }}-${{ matrix.test-group }}
354349
path: services/api/junit_xml
355350

356-
- name: Log coverage data files
357-
run: |
358-
find docker_data/owl/db -type f | head -50
359-
find services/api/coverage -type f | head -50
360-
find services/api/junit_xml -type f | head -50
361-
362351
- name: Generate coverage reports
363352
id: generate_coverage_report
364353
if: always() && steps.merge_test_data.outcome == 'success'
@@ -413,18 +402,11 @@ jobs:
413402
pushd services/api
414403
uv pip install --system -e .[test]
415404
416-
- name: Download pytest coverage data artifacts
417-
uses: actions/download-artifact@v4
418-
if: needs.sdk_tests.result == 'success'
419-
with:
420-
pattern: pytest-coverage-data-*
421-
path: ./
422-
423405
- name: Download coverage data artifacts
424406
uses: actions/download-artifact@v4
425407
if: needs.sdk_tests.result == 'success'
426408
with:
427-
pattern: docker_data-coverage-data-*
409+
pattern: owl-coverage-*
428410
path: ./
429411

430412
- name: Download junit xml artifacts
@@ -437,29 +419,36 @@ jobs:
437419
- name: Log coverage data files
438420
if: needs.sdk_tests.result == 'success'
439421
run: |
440-
find docker_data-coverage-data-* -type f | head -50
441-
find pytest-coverage-data-* -type f | head -50
422+
find owl-coverage-* -type f | head -50
442423
find junit-xml-data -type f | head -50
443424
444425
- name: Merge JUnit XML and Coverage data (${{ matrix.jamai-mode }})
445426
id: merge_coverage
446427
if: needs.sdk_tests.result == 'success'
447428
run: |
448429
coverage combine --keep --data-file=services/api/coverage/.coverage --rcfile=services/api/pyproject.toml \
449-
./docker_data-coverage-data-${{ matrix.jamai-mode }}-group[1-4] \
450-
./pytest-coverage-data-${{ matrix.jamai-mode }}-group[1-4]
430+
./owl-coverage-${{ matrix.jamai-mode }}-group[1-4]
451431
452432
# Merge JUnit XML files
453-
junitparser merge --glob "junit-xml-data/junit-xml-data-${{ matrix.jamai-mode }}-*/pytest_*.xml" \
433+
junitparser merge --glob "junit-xml-data/junit-xml-data-${{ matrix.jamai-mode }}*/pytest-*.xml" \
454434
junit-xml-data/pytest-${{ matrix.jamai-mode }}.xml
455435
456436
- name: Generate coverage report
457437
if: always() && steps.merge_coverage.outcome == 'success'
458438
run: |
459439
cd services/api
440+
coverage html --data-file=coverage/.coverage -d coverage/html-${{ matrix.jamai-mode }}
460441
coverage xml --data-file=coverage/.coverage -o coverage/coverage-${{ matrix.jamai-mode }}.xml
461442
coverage report --data-file=coverage/.coverage
462443
444+
- name: Upload ${{ matrix.jamai-mode }} coverage HTML report
445+
id: upload_coverage_html
446+
uses: actions/upload-artifact@v4
447+
if: always() && steps.merge_coverage.outcome == 'success'
448+
with:
449+
name: pytest-coverage-${{ matrix.jamai-mode }}
450+
path: services/api/coverage/html-${{ matrix.jamai-mode }}
451+
463452
- name: Pytest coverage comment
464453
uses: MishaKav/pytest-coverage-comment@main
465454
if: always() && github.event_name == 'pull_request' && steps.merge_coverage.outcome == 'success'
@@ -475,11 +464,10 @@ jobs:
475464
if: needs.sdk_tests.result == 'success' && matrix.jamai-mode == 'oss'
476465
run: |
477466
coverage combine --keep --data-file=services/api/coverage/.coverage --rcfile=services/api/pyproject.toml \
478-
./docker_data-coverage-data-oss-group[1-4] \
479-
./pytest-coverage-data-oss-group[1-4]
467+
./owl-coverage-oss-group[1-4]
480468
481469
# Merge JUnit XML files
482-
junitparser merge --glob "junit-xml-data/junit-xml-data-*/pytest_*.xml" junit-xml-data/pytest.xml
470+
junitparser merge --glob "junit-xml-data/junit-xml-data-*/pytest-*.xml" junit-xml-data/pytest.xml
483471
484472
- name: Generate coverage reports
485473
id: generate_coverage_report
@@ -496,7 +484,6 @@ jobs:
496484
with:
497485
title: Coverage Report (all)
498486
pytest-xml-coverage-path: services/api/coverage/coverage.xml
499-
junitxml-path: junit-xml-data/pytest.xml
500487
unique-id-for-comment: coverage_report_comment_all
501488
report-only-changed-files: true
502489

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919

2020
- name: Set up Python
2121
uses: actions/setup-python@v5
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout code
41-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
4242

4343
- name: Setup Node.js
4444
uses: actions/setup-node@v5

clients/python/src/jamaibase/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,9 @@ async def import_table(
33043304
otherwise OkResponse.
33053305
"""
33063306
migrate = kwargs.pop("migrate", False) # Temporary, may be removed anytime
3307+
reupload = (
3308+
kwargs.pop("reupload", False) or not migrate
3309+
) # Temporary, may be removed anytime, but if migrate == False then this must be True
33073310
timeout = None if migrate else (kwargs.pop("timeout", None) or self.file_upload_timeout)
33083311
v = "v1" if kwargs.pop("v1", False) else "v2"
33093312
mime_type = "application/octet-stream"
@@ -3317,7 +3320,7 @@ async def import_table(
33173320
files={
33183321
"file": (filename, f, mime_type),
33193322
},
3320-
data=dict(**self._process_body(request), migrate=migrate),
3323+
data=dict(**self._process_body(request), migrate=migrate, reupload=reupload),
33213324
timeout=timeout,
33223325
**kwargs,
33233326
)

docker/compose.oss.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include:
2+
- path:
3+
- compose.base.yml
4+
- override.oss.yml

docker/override.oss.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
vmauth:
3+
ports:
4+
- 8427:8427
5+
6+
pgbouncer:
7+
ports:
8+
- 5432:5432
9+
10+
minio:
11+
ports:
12+
- 9000:9000
13+
- 9001:9001
14+
15+
owl:
16+
ports:
17+
- "${API_PORT:-6969}:${OWL_PORT:-6969}"
18+
19+
frontend:
20+
ports:
21+
- "${FRONTEND_PORT:-4000}:4000"

docs/migration_v1_to_v2.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# JamAIBase v1 to v2 migration guide
2+
3+
## Overview
4+
5+
This guide helps migrate your JamAIBase instance from v1 to v2.
6+
7+
## Pre-requisites
8+
9+
- During migration, you will need to have both instances of JamAIBase running concurrently
10+
- For the existing v1 JamAIBase, please re-launch with the new port mapping, to prevent clashing with the v2 instance.
11+
12+
## Launching v1 with updated port mapping
13+
14+
- Update the .env
15+
16+
```
17+
API_PORT=26969
18+
```
19+
20+
- Update the docker/compose.cpu.yml
21+
22+
```
23+
# under the owl service
24+
# from
25+
# image: jamai/owl
26+
# to
27+
image: jamai/owl:v1
28+
```
29+
30+
- Launch v1 JamAIBase with a subset of the services
31+
32+
```
33+
cd /path/to/your/v1/dir
34+
docker compose --env-file .env -f docker/compose.cpu.yml up --scale infinity=0 --scale starling=0 --scale frontend=0 --scale docling=0
35+
```
36+
37+
> if on windows (powershell)
38+
39+
```
40+
cd C:\path\to\your\v1\dir
41+
docker compose -p jamai --env-file .env -f docker/compose.oss.yml up
42+
```
43+
44+
---
45+
46+
## Launching v2
47+
48+
- Launch v2 JamAIBase
49+
50+
```
51+
cd /path/to/your/v2/dir
52+
docker compose -p jamai --env-file .env -f docker/compose.oss.yml up
53+
```
54+
55+
> if on windows (powershell)
56+
57+
```
58+
cd C:\path\to\your\v2\dir
59+
docker compose -p jamai --env-file .env -f docker/compose.oss.yml up
60+
```
61+
62+
## Run the migration
63+
64+
- Install JamAIBase locally
65+
66+
```
67+
cd /path/to/your/v2/dir
68+
cd services/api
69+
pip install -e .
70+
cd -
71+
cd clients/python
72+
pip install -e .
73+
```
74+
75+
> if on windows (powershell)
76+
77+
```
78+
cd C:\path\to\your\v2\dir
79+
80+
cd services\api
81+
pip install -e .
82+
83+
cd ..\..
84+
cd clients\python
85+
pip install -e .
86+
```
87+
88+
- Run the migration scripts
89+
90+
```
91+
# Check your v1 db path
92+
export OWL_V1_DB=/path/to/your/v1/db/main.db
93+
export OWL_V1_FILE=/path/to/your/v1/file # path to your v1 file directory
94+
export OWL_REDIS_HOST=localhost
95+
export OWL_DB_PATH=postgresql+psycopg://owlpguser:owlpgpassword@localhost:5432/jamaibase_owl
96+
97+
python scripts/oss_migrate.py --db_v1_path ${OWL_V1_DB} --migrate --reset --api_base_dst http://localhost:6969/api --api_base_src http://localhost:26969/api --v1_file_path ${OWL_V1_FILE} --s3_endpoint_dst http://localhost:9000
98+
```
99+
100+
> if on windows (powershell)
101+
102+
```
103+
# Set environment variables for the current PowerShell session
104+
# Use Windows-style paths for your files and databases
105+
$env:OWL_V1_DB = "C:\path\to\your\v1\db\main.db"
106+
$env:OWL_V1_FILE = "C:\path\to\your\v1\file"
107+
$env:OWL_REDIS_HOST = "localhost"
108+
$env:OWL_DB_PATH = "postgresql+psycopg://owlpguser:owlpgpassword@localhost:5432/jamaibase_owl"
109+
110+
# Run the migration script
111+
# Note the use of '.\' to execute a script in the current directory
112+
# and $env:VAR_NAME to reference environment variables
113+
python .\scripts\oss_migrate.py --db_v1_path $env:OWL_V1_DB --migrate --reset --api_base_dst http://localhost:6969/api --api_base_src http://localhost:26969/api --v1_file_path $env:OWL_V1_FILE --s3_endpoint_dst http://localhost:9000
114+
```
115+
116+
- If everything successful, you can close the v1 instance

scripts/copy_repo.sh

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

0 commit comments

Comments
 (0)