Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
ad6ecc3
✨ Add LocalBox example script
shroominic Feb 29, 2024
44e1db9
🛠 Adjusted parameter in run
shroominic Feb 29, 2024
6c082ed
🗑️ Removed poetry.lock file
shroominic Feb 29, 2024
85456a9
🚀 Bump version, refine dependencies
shroominic Feb 29, 2024
aa33be5
📦 Update dependencies versions
shroominic Feb 29, 2024
21ae710
🚚 Refactor import paths
shroominic Feb 29, 2024
34f5155
🔄 Rename module imports
shroominic Feb 29, 2024
f639145
🚚 Rename base.py file
shroominic Feb 29, 2024
1382529
🚀 Add LocalBox implementation
shroominic Feb 29, 2024
e854355
🗑️ Remove localbox.py file
shroominic Feb 29, 2024
6cecfac
🚚 Rename remote.py file
shroominic Feb 29, 2024
c9ebbef
🔧 Refactor config handling
shroominic Feb 29, 2024
5f15c9b
🔄 Update error handling structure
shroominic Feb 29, 2024
2ed3d4f
✨ Add py.typed for mypy
shroominic Feb 29, 2024
67bb906
🔄 Refactor utils module paths
shroominic Feb 29, 2024
630254d
🗑️ Removed basebox.py file
shroominic Feb 29, 2024
78d5ac6
🗑️ Removed codebox.py file
shroominic Feb 29, 2024
3e7c3ed
✨ Update ruff settings in pyproject.toml
shroominic Mar 2, 2024
5f4da64
🔼 Upgrade pydantic to 2.6.3
shroominic Mar 2, 2024
d671fc1
🔧 Enhance LocalBox functionality
shroominic Mar 2, 2024
80a362d
📝 Update docstring formatting
shroominic Mar 2, 2024
2b7a559
🔇 Disable test_codebox execution
shroominic Mar 2, 2024
4cb1b3e
📁 Use dynamic working directory
shroominic Mar 2, 2024
cbffe53
✨ Add default_working_dir config
shroominic Mar 2, 2024
4cf247d
✅ Enable test_codebox() function
shroominic Mar 2, 2024
ed0d817
fix
shroominic Mar 3, 2024
140a336
🔧 fix ignoring extra env vars
shroominic Mar 23, 2024
58ef6e2
🔥 Delete .vscode/settings.json
shroominic Mar 23, 2024
bb7fb71
✨ Enhance codeboxapi with RemoteBox support and engine parameter in L…
shroominic Mar 23, 2024
32cedd4
♻️ Refactor tests to simplify asyncio.gather call
shroominic Mar 23, 2024
ec38812
📦 Update pydantic version from 2.6.3 to 2.6.4
shroominic Mar 25, 2024
7cbd8d7
🛠️ Refactor LocalBox class: remove Literal import, add IP configurati…
shroominic Mar 25, 2024
32baae4
🐛 Fix pip install command in LocalBox install and ainstall methods
shroominic Mar 25, 2024
ad3c331
🔧 improve tests
shroominic Mar 26, 2024
c60a01e
🔧 Refactor RemoteBox class to use conditional assignment for aiohttp_…
shroominic Mar 27, 2024
b8a2d40
🧽 pre-commit
shroominic Mar 27, 2024
b7976fa
fix
shroominic Apr 29, 2024
6ea7d2f
🔧 Refactor RemoteBox methods and improve logging in tests
shroominic May 2, 2024
7419d09
Merge branch 'main' into v0.2
shroominic May 9, 2024
6f85896
🔧 Refactor shell command execution to support multiple arguments and …
shroominic May 9, 2024
72094d7
✅ Enhance test coverage for codebox API with additional assertions an…
shroominic May 9, 2024
171bbed
🔧 fix file io due to wrong cwd
shroominic May 13, 2024
84e0b21
wip
shroominic May 28, 2024
15a19a5
wip
shroominic Jun 21, 2024
26e7f1b
rm old examples
shroominic Jun 21, 2024
e812e69
requests to httpx
shroominic Jul 8, 2024
cc3c40a
update deps and optional deps
shroominic Jul 10, 2024
a4fc6c0
📦 container
shroominic Jul 12, 2024
c7ed76c
rm old stuff
shroominic Jul 12, 2024
680e091
new improved base class
shroominic Jul 12, 2024
130a6c2
new improved local box
shroominic Jul 12, 2024
66cabfa
new improved remote box
shroominic Jul 12, 2024
3fb255f
improvements
shroominic Jul 12, 2024
5bb590e
wip
shroominic Jul 12, 2024
64a3652
🐋 docker box
shroominic Jul 12, 2024
d04f046
🔧 dev setup script
shroominic Jul 13, 2024
08c84e5
⚙️ build script
shroominic Jul 14, 2024
6765cdd
🧪 v0.1 tests
shroominic Jul 15, 2024
1ca5d6b
📝 simplify deps
shroominic Jul 17, 2024
bf2a019
🐋📦 container api
shroominic Jul 17, 2024
a8e1db6
rm
shroominic Jul 17, 2024
a741ad6
📂 put everything in utils to look clean
shroominic Jul 17, 2024
676ce27
✨✨insanly improved codebox base class
shroominic Jul 17, 2024
847ef13
✨ way better local box
shroominic Jul 17, 2024
46fed72
✨ ⏫ way simpler remotebox
shroominic Jul 17, 2024
7f0413f
🔧 fix api+remote box sync
shroominic Jul 18, 2024
f99eb64
⛓️ fix ipython streaming
shroominic Jul 19, 2024
90477b6
🐋 simplify docker
shroominic Jul 21, 2024
6aa1aec
rm anyio ref
shroominic Jul 21, 2024
511c47b
📜 update roadmap
shroominic Jul 21, 2024
4c0a5dd
🧪 finally good tests
shroominic Jul 21, 2024
0d737d5
cleanup
shroominic Jul 21, 2024
d383be3
🐋 docker box
shroominic Jul 21, 2024
2fc61f0
cici
shroominic Jul 21, 2024
410e386
fix test01
shroominic Jul 23, 2024
badd0e2
rm pre commit
shroominic Jul 24, 2024
ed25b29
🐋 improve docker build
shroominic Jul 25, 2024
7dc1711
update deps
shroominic Jul 25, 2024
4f5ff81
🐋 build tag push
shroominic Jul 25, 2024
5ecb69e
📦 examples wip
shroominic Jul 25, 2024
176368f
testing fix wip
shroominic Jul 25, 2024
8c2fbff
rm syncify due to many async errors
shroominic Jul 25, 2024
a845e25
🐋📦 fix dockerbox
shroominic Jul 25, 2024
1cf0ef8
🔧 tiny fixes and improvements
shroominic Jul 26, 2024
718e41f
🧪 fix tests
shroominic Jul 26, 2024
bf2cc51
one bug further lol
shroominic Aug 1, 2024
fbbbd68
Merge branch 'main' into v0.2
shroominic Aug 1, 2024
ad8b052
fix container
shroominic Oct 22, 2024
db8d9d4
fix timeout, port, file download
shroominic Oct 24, 2024
01f9666
simplify example
shroominic Oct 24, 2024
0d8216b
fix CodeBoxFile
shroominic Oct 24, 2024
f8b96fb
fix codebox docker
shroominic Oct 24, 2024
83fffe7
remote box fixes
shroominic Oct 24, 2024
15d19fe
fix default values
shroominic Oct 24, 2024
4d02bf9
rm prints, fix async, fix str comparison
shroominic Oct 24, 2024
533c2d5
fix testv01
shroominic Oct 24, 2024
6e42134
improve docker build tagging
shroominic Oct 26, 2024
b742c5c
improve protocol
shroominic Oct 26, 2024
27cd7f6
fix todo
shroominic Oct 26, 2024
1ea5578
fix image matching
shroominic Oct 26, 2024
625b19a
skip docker tests if not running
shroominic Oct 27, 2024
f008b56
migrate v0.2
shroominic Oct 28, 2024
bc8a96b
fix types from CodeBoxFile to RemoteFile
shroominic Oct 28, 2024
1732905
rm unused func
shroominic Oct 28, 2024
16a63ac
upgrade to v0.2
shroominic Oct 28, 2024
e9488b1
add delay measurement
shroominic Oct 28, 2024
88ba047
final api fixes
shroominic Oct 29, 2024
7710a9c
hide docker logs
shroominic Oct 29, 2024
2686388
fix test skipping and typo
shroominic Oct 29, 2024
c46f0b3
rm latest tag
shroominic Oct 29, 2024
e114e51
basic usage examples
shroominic Oct 30, 2024
0194d22
fix async example
shroominic Oct 30, 2024
d47f1b3
fix example
shroominic Oct 30, 2024
d8e5d83
rm example
shroominic Oct 30, 2024
67debe4
parallel exec example with docker
shroominic Oct 30, 2024
eec6072
fix sub inits
shroominic Oct 30, 2024
b32c2c0
update examples
shroominic Oct 30, 2024
2744766
🧑‍🔬 improve tests
shroominic Oct 30, 2024
a45f814
force singelton for localbox
shroominic Oct 30, 2024
3169dbd
add chunk timing example
shroominic Oct 30, 2024
901b32a
fix chunk timing for remote box
shroominic Oct 30, 2024
3cb7c53
rm \n
shroominic Oct 30, 2024
59ea8ee
fix print formatting in example
shroominic Oct 30, 2024
0e10acf
add str repr
shroominic Oct 30, 2024
b7b5651
fix output formatting of extra methods
shroominic Oct 30, 2024
1cce923
fix test chunk sep sleep time
shroominic Oct 30, 2024
341394c
♻️ fix CICD
shroominic Oct 30, 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
8 changes: 3 additions & 5 deletions .github/workflows/auto-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 🔁 Pytest ⏳x60

on:
schedule:
- cron: "0 * * * *"
- cron: "*/60 * * * *"

jobs:
test:
Expand All @@ -14,9 +14,7 @@ jobs:
with:
enable_cache: true
cache_prefix: "venv-codeboxapi"
- name: Sync rye
run: rye sync
- name: Run Pytest
- run: rye sync
- run: rye run pytest
env:
CODEBOX_API_KEY: ${{ secrets.CODEBOX_API_KEY }}
run: rye run pytest
18 changes: 9 additions & 9 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ name: ☑️ CodeCheck
on: [push]

jobs:
pre-commit:
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
runs-on: ubuntu-latest
steps:
pre-commit:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: eifinger/setup-rye@v1
with:
enable-cache: true
cache-prefix: 'venv-codeboxapi'
cache-prefix: "venv-codeboxapi"
- name: pin version
run: rye pin ${{ matrix.python-version }}
- name: Sync rye
run: rye sync
- name: Run pre-commit
run: rye run pre-commit run --all-files
- name: Run ruff
run: rye run ruff check
- name: Run tests
env:
CODEBOX_API_KEY: ${{ secrets.CODEBOX_API_KEY }}
Expand Down
23 changes: 0 additions & 23 deletions .pre-commit-config.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"command": "bash ./scripts/dev-setup.sh",
"group": "build",
"label": "dev-setup",
"runOptions": {
"runOn": "default"
}
}
]
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ghcr.io/astral-sh/uv as uv

FROM --platform=amd64 python:3.11-slim as build

ENV VIRTUAL_ENV=/.venv PATH="/.venv/bin:$PATH"

COPY --from=uv /uv /uv
COPY README.md pyproject.toml src /

RUN --mount=type=cache,target=/root/.cache/uv \
--mount=from=uv,source=/uv,target=/uv \
/uv venv /.venv && /uv pip install -e .[all] \
&& rm -rf README.md pyproject.toml src

# FROM --platform=amd64 python:3.11-slim as runtime

ENV PORT=8069
EXPOSE $PORT

CMD ["/.venv/bin/python", "-m", "codeboxapi.api"]
3 changes: 2 additions & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The configuration settings are encapsulated within the `CodeBoxSettings` class, which inherits from Pydantic's `BaseSettings` class.

`codeboxapi/config.py`

```python
class CodeBoxSettings(BaseSettings):
...
Expand All @@ -22,7 +23,7 @@ class CodeBoxSettings(BaseSettings):

### CodeBox API Settings

- `CODEBOX_API_KEY: Optional[str] = None`
- `CODEBOX_API_KEY: str | None = None`
The API key for CodeBox.

- `CODEBOX_BASE_URL: str = "https://codeboxapi.com/api/v1"`
Expand Down
38 changes: 38 additions & 0 deletions examples/async_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from codeboxapi import CodeBox

codebox = CodeBox()


async def async_examples():
# 1. Async Code Execution
result = await codebox.aexec("print('Async Hello!')")
print(result.text)

# 2. Async File Operations
await codebox.aupload("async_file.txt", b"Async content")

downloaded = await codebox.adownload("async_file.txt")
print("File content:", downloaded.get_content())

# 3. All Sync Methods are also available Async
await codebox.ainstall("requests")

# 4. Async Streaming
async for chunk in codebox.astream_exec("""
for i in range(3):
print(f"Async chunk {i}")
import time
time.sleep(1)
"""):
print(chunk.content, end="")

# 5. Async Streaming Download
async for chunk in codebox.astream_download("async_file.txt"):
assert isinstance(chunk, bytes)
print(chunk.decode())


if __name__ == "__main__":
import asyncio

asyncio.run(async_examples())
44 changes: 0 additions & 44 deletions examples/async_file_io.py

This file was deleted.

72 changes: 0 additions & 72 deletions examples/async_plot_dataset.py

This file was deleted.

37 changes: 0 additions & 37 deletions examples/big_upload.py

This file was deleted.

38 changes: 38 additions & 0 deletions examples/big_upload_from_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from codeboxapi import CodeBox


def url_upload(codebox: CodeBox, url: str) -> None:
codebox.exec(
"""
import requests

def download_file_from_url(url: str) -> None:
response = requests.get(url, stream=True)
response.raise_for_status()
file_name = url.split('/')[-1]
with open('./' + file_name, 'wb') as file:
for chunk in response.iter_content(chunk_size=8192):
if chunk:
file.write(chunk)
"""
)
print(codebox.exec(f"download_file_from_url('{url}')"))


codebox = CodeBox()

url_upload(
codebox,
"https://codeboxapistorage.blob.core.windows.net/bucket/data-test.arrow",
)
print(codebox.list_files())

url_upload(
codebox,
"https://codeboxapistorage.blob.core.windows.net/bucket/data-train.arrow",
)
print(codebox.list_files())

codebox.exec("import os")
print(codebox.exec("print(os.listdir())"))
print(codebox.exec("print([(f, os.path.getsize(f)) for f in os.listdir('.')])"))
Empty file added examples/custom_factory.py.todo
Empty file.
Loading
Loading