opthub_runner


Nameopthub_runner JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/opthub-org/opthub-runner-python
SummaryLibrary for running OptHub problems locally.
upload_time2024-07-29 04:32:51
maintainerNone
docs_urlNone
authorOpthub Inc.
requires_python<4.0,>=3.10
licenseMIT
keywords opthub runner evaluator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [日本語版](https://github.com/opthub-org/opthub-runner-python/blob/main/README_ja.md) 👈

# opthub-runner-python

![Skills](https://skillicons.dev/icons?i=py,graphql,vscode,github)

opthub-runner-python is a Python package that provides Evaluator for local execution.

- Evaluator: Feature to evaluate solutions locally using Docker Image.

This repository describes how to install opthub-runner-python and use Evaluator.


## Getting Started
First of all, you need to set up the following environment settings in advance.

- Install Python 3.10 or newer.
- Set up pip for package management.
- Install and start Docker.*

\*For Mac users, you can install and start [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/).


After completing the above environment setup, you can install `opthub-runner-python` from PyPI with the following command.

```bash
pip install opthub-runner-python
```

After installation, you can use the Evaluator class by importing it with Python code as follows.

```python
from opthub_runner.evaluator import Evaluator
```

For specific usage of the Evaluator class, please refer to [Usage Example](#usage), [Options](#option), and [Execution Results](#result).

Note that **Docker must be started** to run the code. It will not run properly unless Docker is started.


## Usage Example <span id="usage"></span>
Here is an example how to evaluate a solution using the Sphere function with the optimal solution as `[1, 1]` below.

```python
from opthub_runner.evaluator import Evaluator



evaluator = Evaluator("opthub/sphere:latest",
                      {"SPHERE_OPTIMA": [[1, 1]]}) # Initialize Evaluator

x = [0, 2] # Solution to evaluate
result = evaluator.run(x) # Evaluate

print(result) # {'objective': 2, 'feasible': None, 'constraint': None, 'info': None}
```

In the initialization of the Evaluator, the Docker Image `opthub/sphere:latest` of the Sphere function and the environment variable `SPHERE_OPTIMA` of the Docker process are set. The `run` method then starts the Docker process internally and evaluates the solution `[0, 2]`.

Information on the solutions input to the `run` method and the Docker image to be used are described in each problem on [OptHub](https://opthub.ai).

## Options <span id="option"></span>
The options used to initialize the Evaluator class are listed in the table below (* is required).

| Option | Type | Default Value | Description |
|----|----|----|----|
| docker_image* | str| - | Name of the Docker Image used for evaluation. |
| environment* | dict[str, object] | - | Environment variables. |
| rm | bool | True | Whether to remove the Docker Container after evaluation. |
|timeout | int | 43200 | Timeout for evaluation using Docker Image. |

## Execution Results <span id="result"></span>
The `run` method of the Evaluator class returns the evaluation result. The evaluation result is represented by a dictionary object containing pairs of Key and the corresponding Value. The following table shows the Keys and the types of the Values corresponding to the Keys included in the evaluation result.

| Key | Type of Value | Description |
|----|----|----|
| objective | object | Objective function value of the solution. |
| feasible | bool or None | Feasibility of the solution. |
| constraint | object or None | Information on solution constraints. |
| info | object or None | Information on evaluation. |

Detailed descriptions of objective, constraint, feasible, and info are provided in each problem on [OptHub](https://opthub.ai).

## Troubleshooting
If you receive the following error, Docker is most likely not running. Please start Docker and re-run it. if you are Mac users, you can start Docker by launching Docker Desktop.

```shell
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
```

## For Contributors

Follow these steps to set up the environment:

1. Clone this repository.
2. Set up Poetry.
3. Run `poetry install`.
4. Download the recommended VSCode Extensions.
5. Disable the following VS Code Extensions for this workspace to avoid conflicts with other packages:
    - ms-python.pylint
    - ms-python.black-formatter
    - ms-python.flake8
    - ms-python.isort

## Contact <a id="Contact"></a>

If you have any questions or concerns, please feel free to contact us (Email: dev@opthub.ai).

<img src="https://opthub.ai/assets/images/logo.svg" width="200">

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opthub-org/opthub-runner-python",
    "name": "opthub_runner",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "opthub, runner, evaluator",
    "author": "Opthub Inc.",
    "author_email": "dev@opthub.ai",
    "download_url": "https://files.pythonhosted.org/packages/c6/1c/f09cd1df938d1ed50fad732f1a345cade2cb434ed2ca2068eed7114e68d1/opthub_runner-0.1.1.tar.gz",
    "platform": null,
    "description": "[\u65e5\u672c\u8a9e\u7248](https://github.com/opthub-org/opthub-runner-python/blob/main/README_ja.md) \ud83d\udc48\n\n# opthub-runner-python\n\n![Skills](https://skillicons.dev/icons?i=py,graphql,vscode,github)\n\nopthub-runner-python is a Python package that provides Evaluator for local execution.\n\n- Evaluator: Feature to evaluate solutions locally using Docker Image.\n\nThis repository describes how to install opthub-runner-python and use Evaluator.\n\n\n## Getting Started\nFirst of all, you need to set up the following environment settings in advance.\n\n- Install Python 3.10 or newer.\n- Set up pip for package management.\n- Install and start Docker.*\n\n\\*For Mac users, you can install and start [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/).\n\n\nAfter completing the above environment setup, you can install `opthub-runner-python` from PyPI with the following command.\n\n```bash\npip install opthub-runner-python\n```\n\nAfter installation, you can use the Evaluator class by importing it with Python code as follows.\n\n```python\nfrom opthub_runner.evaluator import Evaluator\n```\n\nFor specific usage of the Evaluator class, please refer to [Usage Example](#usage), [Options](#option), and [Execution Results](#result).\n\nNote that **Docker must be started** to run the code. It will not run properly unless Docker is started.\n\n\n## Usage Example <span id=\"usage\"></span>\nHere is an example how to evaluate a solution using the Sphere function with the optimal solution as `[1, 1]` below.\n\n```python\nfrom opthub_runner.evaluator import Evaluator\n\n\n\nevaluator = Evaluator(\"opthub/sphere:latest\",\n                      {\"SPHERE_OPTIMA\": [[1, 1]]}) # Initialize Evaluator\n\nx = [0, 2] # Solution to evaluate\nresult = evaluator.run(x) # Evaluate\n\nprint(result) # {'objective': 2, 'feasible': None, 'constraint': None, 'info': None}\n```\n\nIn the initialization of the Evaluator, the Docker Image `opthub/sphere:latest` of the Sphere function and the environment variable `SPHERE_OPTIMA` of the Docker process are set. The `run` method then starts the Docker process internally and evaluates the solution `[0, 2]`.\n\nInformation on the solutions input to the `run` method and the Docker image to be used are described in each problem on [OptHub](https://opthub.ai).\n\n## Options <span id=\"option\"></span>\nThe options used to initialize the Evaluator class are listed in the table below (* is required).\n\n| Option | Type | Default Value | Description |\n|----|----|----|----|\n| docker_image* | str| - | Name of the Docker Image used for evaluation. |\n| environment* | dict[str, object] | - | Environment variables. |\n| rm | bool | True | Whether to remove the Docker Container after evaluation. |\n|timeout | int | 43200 | Timeout for evaluation using Docker Image.\u3000|\n\n## Execution Results <span id=\"result\"></span>\nThe `run` method of the Evaluator class returns the evaluation result. The evaluation result is represented by a dictionary object containing pairs of Key and the corresponding Value. The following table shows the Keys and the types of the Values corresponding to the Keys included in the evaluation result.\n\n| Key | Type of Value | Description |\n|----|----|----|\n| objective | object | Objective function value of the solution. |\n| feasible | bool or None | Feasibility of the solution. |\n| constraint | object or None | Information on solution constraints. |\n| info | object or None | Information on evaluation. |\n\nDetailed descriptions of objective, constraint, feasible, and info are provided in each problem on [OptHub](https://opthub.ai).\n\n## Troubleshooting\nIf you receive the following error, Docker is most likely not running. Please start Docker and re-run it. if you are Mac users, you can start Docker by launching Docker Desktop.\n\n```shell\ndocker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))\n```\n\n## For Contributors\n\nFollow these steps to set up the environment:\n\n1. Clone this repository.\n2. Set up Poetry.\n3. Run `poetry install`.\n4. Download the recommended VSCode Extensions.\n5. Disable the following VS Code Extensions for this workspace to avoid conflicts with other packages:\n    - ms-python.pylint\n    - ms-python.black-formatter\n    - ms-python.flake8\n    - ms-python.isort\n\n## Contact <a id=\"Contact\"></a>\n\nIf you have any questions or concerns, please feel free to contact us (Email: dev@opthub.ai).\n\n<img src=\"https://opthub.ai/assets/images/logo.svg\" width=\"200\">\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library for running OptHub problems locally.",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://github.com/opthub-org/opthub-runner-python",
        "Homepage": "https://github.com/opthub-org/opthub-runner-python",
        "Repository": "https://github.com/opthub-org/opthub-runner-python"
    },
    "split_keywords": [
        "opthub",
        " runner",
        " evaluator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2b9bce228bcb5a96658d9befe4704b998fdcf6425deb4f9872abaff29199778",
                "md5": "3759203adb7c94ace09c4f4b34289139",
                "sha256": "e5feba2f2869f28941956df10462bfdd4e526e3d91be7878c614b84859c68307"
            },
            "downloads": -1,
            "filename": "opthub_runner-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3759203adb7c94ace09c4f4b34289139",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6525,
            "upload_time": "2024-07-29T04:32:49",
            "upload_time_iso_8601": "2024-07-29T04:32:49.781001Z",
            "url": "https://files.pythonhosted.org/packages/e2/b9/bce228bcb5a96658d9befe4704b998fdcf6425deb4f9872abaff29199778/opthub_runner-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c61cf09cd1df938d1ed50fad732f1a345cade2cb434ed2ca2068eed7114e68d1",
                "md5": "e543d8da887826a1b8d99d1de9b792f5",
                "sha256": "9cd233a42d0cda6b38aa52313802d19c5929c5f33594ad74320422a98ef090e4"
            },
            "downloads": -1,
            "filename": "opthub_runner-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e543d8da887826a1b8d99d1de9b792f5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 5850,
            "upload_time": "2024-07-29T04:32:51",
            "upload_time_iso_8601": "2024-07-29T04:32:51.027964Z",
            "url": "https://files.pythonhosted.org/packages/c6/1c/f09cd1df938d1ed50fad732f1a345cade2cb434ed2ca2068eed7114e68d1/opthub_runner-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-29 04:32:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opthub-org",
    "github_project": "opthub-runner-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "opthub_runner"
}
        
Elapsed time: 1.32932s