onecode


Nameonecode JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/deeplime-io/onecode
SummaryPython skeleton and library for OneCode projects
upload_time2024-06-05 17:14:58
maintainerNone
docs_urlNone
authorDeepLime
requires_python<3.13,>=3.8
licenseMIT
keywords onecode share deploy cloud
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![onecode_logo](https://github.com/deeplime-io/onecode/raw/1.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/1.x/graph/badge.svg?token=BF54VNGWM5)](https://codecov.io/gh/deeplime-io/onecode)

---

OneCode, your gateway to Python application deployment on the Cloud!
Pssst, if you're not into rolling out your App but simply using them, check out the [OneCode Cloud user doc](https://deeplime-io.github.io/onecode/1.0.0/user_doc).

* [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 0.x](#upgrading-from-0x)
* [Work in Progress](#work-in-progress)
* [Getting Help](#getting-help)


## :snake: OneCode in One Minute

### Install OneCode

```bash
pip install onecode
```

### Create your first OneCode project

```bash
onecode-create

# then follow the prompts
? Enter the path where to create OneCode project: ~/
? Enter your OneCode project name: HelloWorld

⠋ Creating new OneCode project
✅ Created HelloWorld OneCode project
```

### Add your first OneCode Element

Edit the file `HelloWorld/flows/helloworld.py` such as
```python
from onecode import Logger, text_input


def run():
    Logger.info(f"Hello {text_input('your name', 'OneCoder')}!")

```

### Running your OneCode project

```bash
cd HelloWorld
python main.py

# You should see the following printed
[INFO] helloworld - |OneCode|.helloworld.py:5 - Hello OneCoder!
```

By default, the OneCode text input is `OneCoder` but now can take any other values without having to change the code.

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


## :volcano: Deploy on OneCode Cloud

The following steps will show you how to get setup for the 1st time:

1. Ensure you install at least `onecode >= 1.0.0` and have a [GitHub](https://github.com) account
    * If you have an app with a previous `onecode` version, [upgrade from 0.x](#upgrading-from-0x).
    * [Create](#onecode-in-one-minute) your OneCode App (or use an existing one) and [push it to your GitHub account](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github).

2. Request a beta-tester access [here](https://tally.so/r/mVJbWN).

3. Once you received your confirmation email, login on [onecode.rocks](https://www.onecode.rocks/login).

4. Register your first app
    * From the dashboard, navigate to **Apps** in the top menubar.

    ![OneCode Dashboard](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/dashboard.png)

    * Click on **Register New App**.

    ![OneCode Register App Step 1](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_1.png)

    * On your first visit, you'll need to **Link GitHub Account** to your OneCode account.

    ![OneCode Register App Step 2](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_2.png)

    * As you are redirected to GitHub, login to your GitHub account.

    ![OneCode Register App Step 3](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_3.png)

    * **Authorize OneCode**.

    ![OneCode Register App Step 4](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_4.png)

    * Upon authorization, you will be redirected back to OneCode with your GitHub identity.
    You now need to decide which repositories OneCode may access in order to build your app by
    clicking on **GitHub App**.
    ![OneCode Register App Step 5](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_5.png)

    * Choose which repositories should be accessible by OneCode.
    Note that you can change these permissions at anytime.

    ![OneCode Register App Step 6](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_6.png)

    * Select the repository and the branch corresponding to the OneCode App you want to deploy.
    Choose if needed a different image and Python version than the default one.

    ![OneCode Register App Step 7](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_7.png)


5. The App will then appear in your personal Apps Workspace and be automatically built.
Each new commit that you push to the registered branch will automatically trigger a new build

:tada: :tada: :tada: Congratulations, you now are an Cloud OneCoder! :tada: :tada: :tada:


## :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/1.0.0/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/1.0.0/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/1.0.0/reference/elements/input_elements_api)!


## :arrow_up: Upgrading from 0.x

* Ensure there is `requirements.txt` file at the root of your App and that it contains at least `onecode>=1,<2`.

* Change all Output Elements (e.g. `image_output()`, `text_output()`, etc.) to simply `file_output()`.

* Remove any `section_header()` element.

* Check out the [work in progress section](#work-in-progress) in case you were using advanced features.


## :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:

* **Multi-steps**: adding more than one flow to your App will eventually be supported. In the meantime,
either split your app (one app per step) or merge all steps under a single one
(you may directly update the `.onecode.json` file or create a new app and move the code to it).

* **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.

* **Custom Elements** (in custom plugin or `onecode_ext`): extra security precautions must be taken
to allow custom UI on the Cloud. It has therefore been disabled for now.  Replace them with regular elements until the Cloud is ready for them.

* **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.

* **Running `onecode-start`**: getting a local UI is in the works, it's a pretty big feature, thanks
for your patience on that one.


## :wave: Getting Help

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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deeplime-io/onecode",
    "name": "onecode",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "onecode, share, deploy, cloud",
    "author": "DeepLime",
    "author_email": "contact@deeplime.io",
    "download_url": "https://files.pythonhosted.org/packages/a4/fd/b177a22816908e61752070489d71b7c7ba5fdb49a8762f313519a05b31ff/onecode-1.0.0.tar.gz",
    "platform": null,
    "description": "![onecode_logo](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/onecode.jpg)\n\n![GitHub release](https://img.shields.io/github/v/release/deeplime-io/onecode?sort=semver)\n![PyPI - License](https://img.shields.io/pypi/l/onecode)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/onecode)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/deeplime-io/onecode/validation.yml?event=push&label=test%20status)\n![Windows supported](https://img.shields.io/badge/platform-linux-%23f2c300?logo=linux)\n![Linux supported](https://img.shields.io/badge/platform-windows-4287f5?logo=windows)\n![MacOS supported](https://img.shields.io/badge/platform-macos-dedcde?logo=apple)\n[![Maintainability](https://api.codeclimate.com/v1/badges/df236aa4b4ab765ba7db/maintainability)](https://codeclimate.com/github/deeplime-io/onecode/maintainability)\n[![Coverage](https://codecov.io/gh/deeplime-io/onecode/branch/1.x/graph/badge.svg?token=BF54VNGWM5)](https://codecov.io/gh/deeplime-io/onecode)\n\n---\n\nOneCode, your gateway to Python application deployment on the Cloud!\nPssst, if you're not into rolling out your App but simply using them, check out the [OneCode Cloud user doc](https://deeplime-io.github.io/onecode/1.0.0/user_doc).\n\n* [OneCode in One Minute](#onecode-in-one-minute)\n* [Deploy on OneCode Cloud](#deploy-on-onecode-cloud)\n* [Getting Started with the OneCode API](#getting-started-with-the-onecode-api)\n* [Upgrading from 0.x](#upgrading-from-0x)\n* [Work in Progress](#work-in-progress)\n* [Getting Help](#getting-help)\n\n\n## :snake: OneCode in One Minute\n\n### Install OneCode\n\n```bash\npip install onecode\n```\n\n### Create your first OneCode project\n\n```bash\nonecode-create\n\n# then follow the prompts\n? Enter the path where to create OneCode project: ~/\n? Enter your OneCode project name: HelloWorld\n\n\u280b Creating new OneCode project\n\u2705 Created HelloWorld OneCode project\n```\n\n### Add your first OneCode Element\n\nEdit the file `HelloWorld/flows/helloworld.py` such as\n```python\nfrom onecode import Logger, text_input\n\n\ndef run():\n    Logger.info(f\"Hello {text_input('your name', 'OneCoder')}!\")\n\n```\n\n### Running your OneCode project\n\n```bash\ncd HelloWorld\npython main.py\n\n# You should see the following printed\n[INFO] helloworld - |OneCode|.helloworld.py:5 - Hello OneCoder!\n```\n\nBy default, the OneCode text input is `OneCoder` but now can take any other values without having to change the code.\n\n:tada: Congratulations, you now are a OneCoder! :tada:\n\n\n## :volcano: Deploy on OneCode Cloud\n\nThe following steps will show you how to get setup for the 1st time:\n\n1. Ensure you install at least `onecode >= 1.0.0` and have a [GitHub](https://github.com) account\n    * If you have an app with a previous `onecode` version, [upgrade from 0.x](#upgrading-from-0x).\n    * [Create](#onecode-in-one-minute) your OneCode App (or use an existing one) and [push it to your GitHub account](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github).\n\n2. Request a beta-tester access [here](https://tally.so/r/mVJbWN).\n\n3. Once you received your confirmation email, login on [onecode.rocks](https://www.onecode.rocks/login).\n\n4. Register your first app\n    * From the dashboard, navigate to **Apps** in the top menubar.\n\n    ![OneCode Dashboard](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/dashboard.png)\n\n    * Click on **Register New App**.\n\n    ![OneCode Register App Step 1](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_1.png)\n\n    * On your first visit, you'll need to **Link GitHub Account** to your OneCode account.\n\n    ![OneCode Register App Step 2](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_2.png)\n\n    * As you are redirected to GitHub, login to your GitHub account.\n\n    ![OneCode Register App Step 3](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_3.png)\n\n    * **Authorize OneCode**.\n\n    ![OneCode Register App Step 4](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_4.png)\n\n    * Upon authorization, you will be redirected back to OneCode with your GitHub identity.\n    You now need to decide which repositories OneCode may access in order to build your app by\n    clicking on **GitHub App**.\n    ![OneCode Register App Step 5](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_5.png)\n\n    * Choose which repositories should be accessible by OneCode.\n    Note that you can change these permissions at anytime.\n\n    ![OneCode Register App Step 6](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_6.png)\n\n    * Select the repository and the branch corresponding to the OneCode App you want to deploy.\n    Choose if needed a different image and Python version than the default one.\n\n    ![OneCode Register App Step 7](https://github.com/deeplime-io/onecode/raw/1.x/docs/assets/app_rego_step_7.png)\n\n\n5. The App will then appear in your personal Apps Workspace and be automatically built.\nEach new commit that you push to the registered branch will automatically trigger a new build\n\n:tada: :tada: :tada: Congratulations, you now are an Cloud OneCoder! :tada: :tada: :tada:\n\n\n## :rocket: Getting Started with the OneCode API\n\nOneCode relies on the following principles:\n\n* **no-disruption**: OneCode doesn't force you to change the way you code. No matter what your code structure and\nPython files hierarchy, OneCode can seamlessly be integrated with it.\n\n* **controllable input parameters**: simply replace your hard-coded parameters with OneCode functions\n(called **Elements**) so that their value can change without having to change the code. One Code, many ways to run!\n\n* **automated interface**: OneCode push on the cloud, the interface will automatically be generated from the OneCode\nElements\n\n* **easy deployment**: no need to change the code between your local machine and the cloud. Simply push your code\nas-is on your synchronized GitHub account and your App (environment and UI!) will build automatically!\n\n\nThe most important part of the API are Input and Output Elements. They can be inlined within your code\nor not, that's up to you (no-disruption!), see examples below:\n\n* use [Input Elements](https://deeplime-io.github.io/onecode/1.0.0/reference/elements/element_list/#input-elements) whenever you need to expose a parameter\nwith a specific widget. For example:\n```python\n# instead of: df = pd.read_csv('test.csv')\ndf = csv_reader('your df', 'test.csv')\n\n# instead of: for i in range(5):\nfor i in range(slider('N', 5, min=0, max=10)):  # inlined\n    # do stuff\n\n# instead of: choice = 'cat'\nchoice = dropdown('your choice', 'cat', options=['dog', 'cat', 'fish']) # not inlined\nLogger.info(f'Your choice is {choice}')\n```\n\n* use [Output Elements](https://deeplime-io.github.io/onecode/1.0.0/reference/elements/element_list/#output-elements) whenever an output should be returned. For example:\n```python\n# instead of: plt.savefig('stuff.png')\nplt.savefig(file_output('stuff', 'stuff.png'))  # inlined\n\n# instead of: filepath = 'test.txt'\nfilepath = file_output('test', 'test.txt')  # not inlined\nwith open(filepath, 'w') as f:\n    # do stuff\n```\n\nCheck out the full API documentation [here](https://deeplime-io.github.io/onecode/1.0.0/reference/elements/input_elements_api)!\n\n\n## :arrow_up: Upgrading from 0.x\n\n* Ensure there is `requirements.txt` file at the root of your App and that it contains at least `onecode>=1,<2`.\n\n* Change all Output Elements (e.g. `image_output()`, `text_output()`, etc.) to simply `file_output()`.\n\n* Remove any `section_header()` element.\n\n* Check out the [work in progress section](#work-in-progress) in case you were using advanced features.\n\n\n## :construction: Work in Progress\n\nAs `onecode` is still transitioning to OneCode Cloud, early versions of the OneCode Cloud don't yet\nsupport completely the following features:\n\n* **Multi-steps**: adding more than one flow to your App will eventually be supported. In the meantime,\neither split your app (one app per step) or merge all steps under a single one\n(you may directly update the `.onecode.json` file or create a new app and move the code to it).\n\n* **Folder Inputs**: as the cloud doesn't really have directory structures, it needs some special work.\nIn the meantime, replace with multiple selection `file_input` instead.\n\n* **Custom Elements** (in custom plugin or `onecode_ext`): extra security precautions must be taken\nto allow custom UI on the Cloud. It has therefore been disabled for now.  Replace them with regular elements until the Cloud is ready for them.\n\n* **Dynamic `options`**: dynamic expressions in `options` of the `dropdown` element) is not fully\nsupported yet. You can still use it, in that case, the elements will ask user to fill out values\nas regular text input (e.g. CSV column names, etc.).\n\n* **Dynamic `optional`**: `optional` as `True/False` (static) works as expected, however dynamnic\nexpressions will be ignored for now. As a consequence, `hide_when_disabled` attribute is obsolete\nuntil dynamic `optional` are supported again.\n\n* **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.\n\n* **Running `onecode-start`**: getting a local UI is in the works, it's a pretty big feature, thanks\nfor your patience on that one.\n\n\n## :wave: Getting Help\n\nIf you are a OneCode customer, you may directly email our support team.\nFeel free as well to browse the [GitHub Issues](https://github.com/deeplime-io/onecode/issues)\nand reach out to the community by posting bug reports, questions and suggestions.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python skeleton and library for OneCode projects",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://deeplime-io.github.io/onecode",
        "Homepage": "https://github.com/deeplime-io/onecode",
        "Repository": "https://github.com/deeplime-io/onecode"
    },
    "split_keywords": [
        "onecode",
        " share",
        " deploy",
        " cloud"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f7dcdb1ea559bfec68399d974653f2226c299a7311346ec6c49a2f02f80c18e",
                "md5": "f1faefd796bc19794df73be2274767cc",
                "sha256": "547706b71168ba646cdb30a6e7db81e26b01ab959539ea766b74e721da3fee23"
            },
            "downloads": -1,
            "filename": "onecode-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f1faefd796bc19794df73be2274767cc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.8",
            "size": 62964,
            "upload_time": "2024-06-05T17:14:56",
            "upload_time_iso_8601": "2024-06-05T17:14:56.208274Z",
            "url": "https://files.pythonhosted.org/packages/8f/7d/cdb1ea559bfec68399d974653f2226c299a7311346ec6c49a2f02f80c18e/onecode-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4fdb177a22816908e61752070489d71b7c7ba5fdb49a8762f313519a05b31ff",
                "md5": "ad84833be2615962783f2d929d48fb9b",
                "sha256": "f084ea357a58067e55206ac7e0ec99f9bac724fe6788ae070070ccabbf209382"
            },
            "downloads": -1,
            "filename": "onecode-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ad84833be2615962783f2d929d48fb9b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 39357,
            "upload_time": "2024-06-05T17:14:58",
            "upload_time_iso_8601": "2024-06-05T17:14:58.273395Z",
            "url": "https://files.pythonhosted.org/packages/a4/fd/b177a22816908e61752070489d71b7c7ba5fdb49a8762f313519a05b31ff/onecode-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-05 17:14:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deeplime-io",
    "github_project": "onecode",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "onecode"
}
        
Elapsed time: 0.25963s