Metadata-Version: 2.4
Name: onecode
Version: 2.0.0rc1
Summary: Python skeleton and library for OneCode projects
License: MIT
License-File: LICENSE
Keywords: onecode,share,deploy,cloud
Author: DeepLime
Author-email: contact@deeplime.io
Requires-Python: >=3.11,<3.15
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Code Generators
Provides-Extra: developer
Provides-Extra: docs
Requires-Dist: datatest (>=0.11.1,<1) ; extra == "developer"
Requires-Dist: filelock (>=3.30,<5)
Requires-Dist: griffe (>=2,<3) ; extra == "docs"
Requires-Dist: mike (>=2,<3) ; extra == "docs"
Requires-Dist: mkdocs (>=1.6,<2) ; extra == "docs"
Requires-Dist: mkdocs-material (>=9.7.7,<10) ; extra == "docs"
Requires-Dist: mkdocstrings (>=1,<2) ; extra == "docs"
Requires-Dist: mkdocstrings-python (>=2,<3) ; extra == "docs"
Requires-Dist: pandas (>=2.3,<4)
Requires-Dist: pyarrow (>=22,<26)
Requires-Dist: pydash (>=7,<9)
Requires-Dist: pytest (>=9.0.3,<10) ; extra == "developer"
Requires-Dist: pytest-cov (>=6,<8) ; extra == "developer"
Requires-Dist: pytest-xdist (>=3.6,<4) ; extra == "developer"
Requires-Dist: python-slugify (>=8,<10)
Requires-Dist: yaspin (>=3,<4)
Project-URL: Documentation, https://deeplime-io.github.io/onecode
Project-URL: Homepage, https://github.com/deeplime-io/onecode
Project-URL: Repository, https://github.com/deeplime-io/onecode
Project-URL: SBOM, https://github.com/deeplime-io/onecode/releases/latest
Description-Content-Type: text/markdown

![onecode_logo](https://github.com/deeplime-io/onecode/raw/2.x/docs/assets/onecode.jpg)

![GitHub release](https://img.shields.io/github/v/release/deeplime-io/onecode?sort=semver)
![PyPI - License](https://img.shields.io/pypi/l/onecode)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/onecode)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/deeplime-io/onecode/validation.yml?event=push&label=test%20status)
![Windows supported](https://img.shields.io/badge/platform-linux-%23f2c300?logo=linux)
![Linux supported](https://img.shields.io/badge/platform-windows-4287f5?logo=windows)
![MacOS supported](https://img.shields.io/badge/platform-macos-dedcde?logo=apple)
[![Maintainability](https://api.codeclimate.com/v1/badges/df236aa4b4ab765ba7db/maintainability)](https://codeclimate.com/github/deeplime-io/onecode/maintainability)
[![Coverage](https://codecov.io/gh/deeplime-io/onecode/branch/2.x/graph/badge.svg?token=BF54VNGWM5)](https://codecov.io/gh/deeplime-io/onecode)

---

> **OneCode 2 is for the new OneCode Cloud.** An app is a single `main.py`: flows, `.onecode.json` and
> `onecode_ext` are gone. Apps for the legacy OneCode Cloud stay on 1.3.x, which receives security fixes
> until 30 June 2027 (see [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy)).
> See [Upgrading from 1.x](#upgrading-from-1x).

OneCode, your gateway to Python application deployment on the Cloud!

* [OneCode in One Minute](#onecode-in-one-minute)
* [Deploy on OneCode Cloud](#deploy-on-onecode-cloud)
* [Getting Started with the OneCode API](#getting-started-with-the-onecode-api)
* [Upgrading from 1.x](#upgrading-from-1x)
* [Work in Progress](#work-in-progress)
* [Getting Help](#getting-help)


## :snake: OneCode in One Minute

### Create your first OneCode app

With [uv](https://docs.astral.sh/uv/):

```bash
uvx --from onecode onecode-create "Hello World"

⠋ Creating new OneCode project
✅ Created Hello World OneCode project in ./Hello_World
```

This creates the app in a new `Hello_World` folder:

```
Hello_World/
├── main.py             # your app
├── requirements.txt    # the packages it needs, starting with onecode>=2,<3
├── data/               # input data, and outputs under data/outputs/
├── README.md
├── LICENSE
└── .gitignore
```

### Write your app

Your code goes in the `run()` function of `main.py`. Replace hard-coded values with OneCode
**Elements**, here a text input:

```python
import onecode


def run():
    name = onecode.text_input("name", "World", label="Your name")
    onecode.Logger.info(f"Hello {name}!")


if __name__ == "__main__":
    onecode.main(run)
```

Keep the last two lines: `onecode.main(run)` is what runs the app. Bigger apps add modules or
packages next to `main.py` and import them as usual.

### Run your app

```bash
cd Hello_World
uv venv
uv pip install -r requirements.txt
uv run python main.py

# You should see the following printed
2026-11-29 10:00:00,000 [INFO] main.py:6 - Hello World!
```

The text input takes `World` by default, and any other value without changing the code:

```bash
uv run onecode-extract params.json   # writes {"name": "World"}: edit it
uv run python main.py params.json
```

:tada: Congratulations, you now are a OneCoder! :tada:


## :volcano: Deploy on OneCode Cloud

1. Push your app to a GitHub repository.
2. Register the app on OneCode Cloud with **Register app**, and pick the repository and branch.
3. OneCode Cloud builds it: it installs `requirements.txt`, then runs `onecode-build` to turn
   your input elements into the app's run form.
4. Each run is `python main.py params.json` with the values entered in the form. Files written
   with `file_output()` are the run's results.

Each new commit pushed to the registered branch triggers a new build.


## :rocket: Getting Started with the OneCode API

OneCode relies on the following principles:

* **no-disruption**: OneCode doesn't force you to change the way you code. No matter what your code structure and
Python files hierarchy, OneCode can seamlessly be integrated with it.

* **controllable input parameters**: simply replace your hard-coded parameters with OneCode functions
(called **Elements**) so that their value can change without having to change the code. One Code, many ways to run!

* **automated interface**: OneCode push on the cloud, the interface will automatically be generated from the OneCode
Elements

* **easy deployment**: no need to change the code between your local machine and the cloud. Simply push your code
as-is on your synchronized GitHub account and your App (environment and UI!) will build automatically!


The most important part of the API are Input and Output Elements. They can be inlined within your code
or not, that's up to you (no-disruption!), see examples below:

* use [Input Elements](https://deeplime-io.github.io/onecode/latest/reference/elements/element_list/#input-elements) whenever you need to expose a parameter
with a specific widget. For example:
```python
# instead of: df = pd.read_csv('test.csv')
df = csv_reader('your df', 'test.csv')

# instead of: for i in range(5):
for i in range(slider('N', 5, min=0, max=10)):  # inlined
    # do stuff

# instead of: choice = 'cat'
choice = dropdown('your choice', 'cat', options=['dog', 'cat', 'fish']) # not inlined
Logger.info(f'Your choice is {choice}')
```

* use [Output Elements](https://deeplime-io.github.io/onecode/latest/reference/elements/element_list/#output-elements) whenever an output should be returned. For example:
```python
# instead of: plt.savefig('stuff.png')
plt.savefig(file_output('stuff', 'stuff.png'))  # inlined

# instead of: filepath = 'test.txt'
filepath = file_output('test', 'test.txt')  # not inlined
with open(filepath, 'w') as f:
    # do stuff
```

Check out the full API documentation [here](https://deeplime-io.github.io/onecode/latest/reference/elements/input_elements_api)!


## :arrow_up: Upgrading from 1.x

An app with one flow (the usual case) moves in a few steps:

1. Move the body of `flows/<id>.py` into `main.py`, keep `def run()`, and end the file with:
    ```python
    if __name__ == "__main__":
        onecode.main(run)
    ```
2. Move helper modules out of `flows/`, next to `main.py` or into a package, and turn relative
   imports such as `from .utils import x` into `from utils import x`.
3. Delete `.onecode.json`, `flows/` and any `flows/onecode_ext/`.
4. In `requirements.txt`, change `onecode>=1,<2` to `onecode>=2,<3`.
5. Drop reads of `Project().current_flow`. Code that opens `outputs/<flow>/MANIFEST.txt` itself
   now opens `outputs/MANIFEST.txt`.

Element keys, parameters files, the `data/` layout and `file_output()` paths do not change, so
saved parameters keep working. The OneCode 2 CLIs stop with `1.x project: pin onecode<2` when
they find a `.onecode.json`.

`python main.py` no longer takes `--flow` or `--flush`. `onecode-add`, `onecode-start`,
`onecode-zip` and `onecode-check` are removed. See the [2.0.0 changelog](https://github.com/deeplime-io/onecode/blob/2.x/docs/changelogs/2.0.0.md)
for the full list.


## :construction: Work in Progress

As `onecode` is still transitioning to OneCode Cloud, early versions of the OneCode Cloud don't yet
support completely the following features:

* **Folder Inputs**: as the cloud doesn't really have directory structures, it needs some special work.
In the meantime, replace with multiple selection `file_input` instead.

* **Dynamic `options`**: dynamic expressions in `options` of the `dropdown` element) is not fully
supported yet. You can still use it, in that case, the elements will ask user to fill out values
as regular text input (e.g. CSV column names, etc.).

* **Dynamic `optional`**: `optional` as `True/False` (static) works as expected, however dynamnic
expressions will be ignored for now. As a consequence, `hide_when_disabled` attribute is obsolete
until dynamic `optional` are supported again.

* **Attribute `count`**: we go back-and-forth with this one on bringing this one to the Cloud. In the meantime, switch back to non-dynamic elements, e.g. multiple dropdown, text input collecting list of values, etc.


## :wave: Getting Help

Security reports go through [private vulnerability reporting](https://github.com/deeplime-io/onecode/security/advisories/new). See [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy). Security fixes are published for the latest 2.x release, and for the 1.3.x line until 30 June 2027.

Issues labeled [`cra-vulnerability`](https://github.com/deeplime-io/onecode/issues?q=is%3Aissue+is%3Aopen+label%3Acra-vulnerability) come from the dependency scan. They are not the place to disclose a new flaw.

If you are a OneCode customer, you may directly email our support team.
Feel free as well to browse the [GitHub Issues](https://github.com/deeplime-io/onecode/issues)
and reach out to the community by posting bug reports, questions and suggestions.

