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
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.py]
max_line_length = 120

[*.{yml,yaml,json}]
indent_size = 2

[*.md]
indent_size = 2
# two trailing spaces are a hard line break in Markdown
trim_trailing_whitespace = false

[*.rst]
indent_size = 3

[Makefile]
indent_style = tab
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Something does not work as documented
labels: bug
---

**What happened**
A clear description of the bug and what you expected instead.

**Minimal reproduction**
```python
# the smallest script that reproduces it
import lithops

fexec = lithops.FunctionExecutor()
```

**Traceback / logs**
```
paste the full traceback; if possible, run with log_level: DEBUG
```

**Environment**
- Lithops version (`lithops --version`):
- Compute backend (e.g. `localhost`, `aws_lambda`, `code_engine`, `aws_ec2`):
- Storage backend (e.g. `localhost`, `aws_s3`, `ibm_cos`):
- Runtime (default or custom image):
- Python version and OS of the client:

<!-- Remove credentials and account IDs from any configuration you paste. -->
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Questions and discussions
url: https://github.com/lithops-cloud/lithops/discussions
about: Usage questions, ideas and general discussion
- name: Security vulnerabilities
url: https://github.com/lithops-cloud/lithops/security/advisories/new
about: Report security issues privately, not as public issues (see SECURITY.md)
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Propose a new feature, backend or API change
labels: enhancement
---

**Use case**
What are you trying to run (workload, scale, compute / storage backend)?

**Problem**
What is slow, expensive or impossible today?

**Proposal**
The API or behaviour you would like.

**Alternatives**
Workarounds you use today.
18 changes: 16 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE → .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
## What and why

<!-- What does this change and why is it needed? Link the issue if there is one. -->

## How it was tested

- [ ] `ruff check .`
- [ ] `pytest -v --backend localhost --storage localhost` (in `lithops/tests`)
- [ ] On a cloud backend: <!-- e.g. aws_lambda + aws_s3 -->

## Checklist

- [ ] Tests cover the new behaviour / the fixed bug (regression test)
- [ ] Docs updated (`docs/`, `README.md`, `config/config_template.yaml` for new config keys)
- [ ] `CHANGELOG.md` entry under the development version

---


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:
Expand All @@ -25,4 +40,3 @@ Developer's Certificate of Origin 1.1
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

10 changes: 5 additions & 5 deletions .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- master
paths:
- 'setup.py'
- 'pyproject.toml'
- 'lithops/**'
- '.github/workflows/python-linting.yml'

Expand All @@ -18,7 +18,7 @@ concurrency:

jobs:

flake8:
ruff:
runs-on: ubuntu-latest
timeout-minutes: 10

Expand All @@ -34,8 +34,8 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -U flake8
pip3 install ruff==0.16.8 # same version as .pre-commit-config.yaml

- name: Lint with flake8
- name: Lint with ruff
run: |
flake8 lithops --count --statistics
ruff check --output-format=github .
2 changes: 1 addition & 1 deletion .github/workflows/tests-all-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml

- name: Install Redis
# There is no Redis build for Windows. The tests that need a server
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- master
paths:
- 'setup.py'
- 'pyproject.toml'
- 'lithops/**'
- '.github/workflows/tests.yml'

Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml

- name: Install Lithops
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ lithops_*.zip
*.txt
*.csv
*.coverage*
.pytest_cache/

# Local Lithops config (may hold credentials)
.lithops_config

# Virtual environments
.env
Expand Down
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.8
hooks:
# configured in pyproject.toml, same as the Python Linting workflow
- id: ruff-check
112 changes: 112 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# AGENTS.md

Instructions for AI coding agents working in this repository (OpenAI Codex, GitHub Copilot
coding agent, Cursor, Gemini CLI, Aider, Claude Code and others). Human contributors should
read [CONTRIBUTING.md](CONTRIBUTING.md); this file summarizes the same rules plus the
architectural context an agent needs.

## Project overview

Lithops is a Python framework that runs unmodified Python functions at scale on serverless
platforms, container and batch services, virtual machines and the local machine, behind one
small API (`FunctionExecutor.call_async()`, `map()`, `map_reduce()`, `wait()`,
`get_result()`, `Storage`). The architecture is described in
[docs/source/design.rst](docs/source/design.rst); read it before changing core code.

- **Client:** where `import lithops` runs. Builds jobs, serializes code and data, invokes the
workers and collects results. All orchestration lives here.
- **Compute backend:** where the workers run, one call each.
- **Object storage:** the only communication bus between client and workers. The client
writes the pickled function and data; workers read their input and write their output and
status back. There are no direct client-worker connections.

## Setup and commands

```bash
pip3 install -e '.[tests,dev]' # editable install + test deps + ruff / pre-commit
# (backend extras: '.[aws]', '.[gcp]', '.[all]', ...)
ruff check . # lint; must pass (config in pyproject.toml, line length 120)

cd lithops/tests
pytest -v --timeout=120 --timeout-method=thread --backend localhost --storage localhost
pytest -v --backend localhost --storage localhost -k test_map # a subset
pytest --collect-only # list the tests
```

**Always pass `--backend localhost --storage localhost`.** Without them the test session
loads the developer's own configuration (`~/.lithops/config`, `.lithops_config`,
`LITHOPS_CONFIG_FILE`) and runs against whatever cloud account it points to. Some tests need a
Redis server on `localhost:6379` and skip themselves when none is reachable.

Documentation is built with Sphinx from `docs/` (`make html`, see [docs/README.md](docs/README.md)).

## Repository map

| Path | Content |
|---|---|
| `lithops/__init__.py` | Public API surface (`FunctionExecutor`, `Storage`, `wait`, `get_result`, ...) |
| `lithops/executors.py` | `FunctionExecutor` and `LocalhostExecutor` / `ServerlessExecutor` / `StandaloneExecutor` |
| `lithops/config.py` | Loads and merges configuration (dict, env vars, YAML), validates backends |
| `lithops/job/` | Job creation, function/module serialization (`cloudpickle`), data partitioning |
| `lithops/invokers.py` | `FaaSInvoker` (per-call invocations) and `BatchInvoker` (one submission, many tasks) |
| `lithops/future.py`, `wait.py`, `retries.py` | `ResponseFuture`, `wait()` / `get_result()`, `RetryingFunctionExecutor` |
| `lithops/worker/` | Code that runs on the compute backend: `handler.py` (`function_handler`) and `jobrunner.py` (`JobRunner`) |
| `lithops/serverless/backends/<name>/` | Serverless / batch compute backends (`<name>.py`, `config.py`, `entry_point.py`) |
| `lithops/standalone/` | Standalone mode: master / worker VMs coordinated through Redis; `backends/<name>/` for VM providers |
| `lithops/localhost/` | Localhost compute backend (`v1`, `v2`) |
| `lithops/storage/` | `Storage` / `InternalStorage`, cloud file APIs; `backends/<name>/` for object stores |
| `lithops/monitoring/` | Job monitor and its pluggable backends (storage polling, RabbitMQ, Redis, queues) |
| `lithops/telemetry/` | Prometheus / OpenTelemetry metrics (off by default) |
| `lithops/multiprocessing/`, `concurrent/`, `util/joblib/` | Drop-in `multiprocessing`, `concurrent.futures` and joblib APIs |
| `lithops/scripts/` | `lithops` CLI (`cli.py`) and the temporary-data cleaner |
| `lithops/tests/` | pytest suite (`conftest.py` defines `--backend`, `--storage`, `--config`, `--region`) |
| `runtime/<backend>/` | Dockerfiles and instructions to build runtimes for each backend |
| `config/` | `config_template.yaml` (every configuration key) and the configuration guide |
| `docs/` | Sphinx documentation; `docs/source/compute_config/` and `storage_config/` per backend |
| `examples/` | Single-file usage examples |

## Architectural invariants

1. **Storage is the bus.** Workers receive their input and return their results and status
through object storage (`func_key`, `agg_data`, `output_key`, `status_key`), never through
a direct connection to the client.
2. **Every backend looks the same to the core.** Backend-specific code stays in its backend
package; the executor, invoker, job and worker code must not special-case a backend by
name when an interface method or a config value can express it.
3. **The worker must tolerate the environment it runs in.** Worker code runs in minimal
runtimes (Lambda, containers, VMs, macOS/Windows localhost). Imports of optional
dependencies stay lazy, and a failure in the user's function is reported in its status
rather than crashing the worker.
4. **Configuration keys are documented where users look for them.** A new or changed key goes
into `config/config_template.yaml` and the backend's page in `docs/source/compute_config/`
or `docs/source/storage_config/` (general `lithops` keys also in
`docs/source/lithops_config_keys.csv`).
5. **Public API compatibility.** `FunctionExecutor`, `Storage`, futures and the
`multiprocessing` / `concurrent.futures` layers are used by existing programs; do not
change signatures or defaults without a deprecation path and a CHANGELOG entry.

## Conventions

- Python 3.10 - 3.14 (the versions CI tests). Match the style of the surrounding code;
`ruff check .` clean with line length 120. Do not run `ruff format`: the code base is not
formatted with it and it would rewrite almost every file.
- Package metadata, dependencies and extras live in `pyproject.toml`. When adding a
dependency to an extra, also add it to the `all` extra.
- Every bug fix includes a regression test; every feature includes tests of its behaviour.
Tests must run on the localhost backend and storage; backend-specific code that cannot be
exercised locally is tested with fakes or mocks.
- User-visible changes go into `CHANGELOG.md` under the topmost (development) version
heading, in the *Added / Changed / Fixed / Removed* section, prefixed with the component,
e.g. `- [Monitoring] ...`. Update `docs/` and `README.md` when behaviour changes.
- `CONTRIBUTING.md` and `docs/source/contributing.rst` carry the same content: change both.
- Pull requests target `master`. Keep changes small and focused; do not refactor unrelated
code.

## Safety

- Do not run tests, examples or `lithops` CLI commands against real cloud backends (AWS, GCP,
Azure, IBM Cloud, Aliyun, Oracle, Kubernetes clusters) and do not build or push runtime
images without the maintainer's explicit approval: it creates billable resources and uses
real credentials.
- Never commit credentials or configuration files (`~/.lithops/config`, `.lithops_config`).
- Do not commit or push unless asked to.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- [Storage] `CloudFileProxy.walk()` matches `os.walk` on a missing path; `cloud_open()` rejects an unsupported mode.
- [CLI] `job list`, `worker list`, `image delete` and `image list` reject unknown flags.
- [Joblib] `lithops_args` applied to the batch pool; upload/download pools capped at 32 threads.
- [Packaging] Package metadata moved from `setup.py` / `setup.cfg` to `pyproject.toml`; `python_requires` raised to `>=3.10`, matching the tested versions.
- [Development] Linting moved from flake8 to ruff (`ruff check .`, line length 120); new `dev` extra, pre-commit hooks, `.editorconfig`, `AGENTS.md`, `SECURITY.md` and issue / PR templates.

### Fixed
- [Core] Serialization, executor IDs, `FuturesList`, module inspection, `chunksize=0`, packaging, ports, and Ctrl+C/`sys.exit()`.
Expand Down
18 changes: 18 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CLAUDE.md

Claude Code reads this file automatically. The project instructions shared by all AI coding
agents live in [AGENTS.md](AGENTS.md) and are imported here, so there is a single source of
truth:

@AGENTS.md

## Claude Code specifics

- Use the Python interpreter that has this checkout installed in editable mode
(`pip show lithops` shows the *Editable project location*).
- Run `ruff check .` and the localhost test suite (with `--backend localhost --storage
localhost`) before reporting a change as done.
- Long-running jobs (full test suite, Docker / runtime builds, docs builds) should run in the
background.
- Ask before any action that uses cloud accounts, builds or pushes runtime images, or
publishes content.
Loading
Loading