diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1b86e8a..94dcaed 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,26 +1,41 @@ name: publish on: - release: - types: [created] + release: + types: [created] jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + publish: + runs-on: ubuntu-latest + steps: + - name: git clone + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: install dependencies + run: | + pip install --upgrade pip + pip install build twine + + - name: build binary wheel and source tarball + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m build + + - name: publish to TestPyPI + env: + TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }} + run: twine upload --repository testpypi dist/* + + - name: publish to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: twine upload dist/* diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 3c52586..634fe24 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -8,7 +8,7 @@ jobs: python-version: ["3.10", "3.11", "3.12"] steps: - name: git clone - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 8224085..0e9af42 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -8,7 +8,7 @@ jobs: python-version: ["3.10", "3.11", "3.12"] steps: - name: git clone - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/README.md b/README.md index 6ef3e21..deae308 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,71 @@ -# nextmv python package +# Nextmv Python SDK -This is a placeholder for Nextmv's Python package. Stay tuned for more information. +This is the Python SDK for the Nextmv Platform. Before starting: + +1. [Sign up][signup] for a Nextmv account. +2. Get your API key. Go to [Team > API Key][api-key]. + +Visit the [docs][docs] for more information. + +## Installation + +Install using `pip`: + +```bash +pip install nextmv +``` + +## Usage + +Make sure that you have your API key set as an environment variable: + +```bash +export NEXTMV_API_KEY= +``` + +Additionally, you must have a valid app in the Nextmv Cloud. + +- Make a run and get the results. + +```python +import os + +from nextmv.cloud import Application, Client + +input = { + "defaults": {"vehicles": {"speed": 20}}, + "stops": [ + { + "id": "Nijō Castle", + "location": {"lon": 135.748134, "lat": 35.014239}, + "quantity": -1, + }, + { + "id": "Kyoto Imperial Palace", + "location": {"lon": 135.762057, "lat": 35.025431}, + "quantity": -1, + }, + ], + "vehicles": [ + { + "id": "v2", + "capacity": 2, + "start_location": {"lon": 135.728898, "lat": 35.039705}, + }, + ], +} + +client = Client(api_key=os.getenv("NEXTMV_API_KEY")) +app = Application(client=client, id="your-app-id") +result = app.new_run_with_result( + input=input, + instance_id="latest", + run_options={"solve.duration": "1s"}, +) +print(result.to_dict()) + +``` + +[signup]: https://cloud.nextmv.io +[docs]: https://nextmv.io/docs +[api-key]: https://cloud.nextmv.io/team/api-keys diff --git a/pyproject.toml b/pyproject.toml index 7215bdd..609744c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,28 +1,45 @@ [build-system] -requires = ["hatchling >= 1.13.0"] build-backend = "hatchling.build" +requires = ["hatchling >= 1.13.0"] [project] -name = "nextmv" -description = "The Python SDK for Nextmv" -readme = "README.md" -requires-python = ">=3.10" -license = {file = "LICENSE"} authors = [ - { name = "Nextmv", email = "tech@nextmv.io" } + { email = "tech@nextmv.io", name = "Nextmv" } ] -keywords = ["nextmv", "optimization", "solver", "vehicle routing problem", "operations research", "decisions", "decision engineering"] classifiers = [ - "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", + "Programming Language :: Python :: 3", ] -version = "0.1.0" +dependencies = [ + "pydantic>=2.5.2", + "requests>=2.31.0", +] +description = "The Python SDK for Nextmv" +keywords = [ + "decision engineering", + "decision science", + "decisions", + "nextmv", + "optimization", + "operations research", + "shift scheduling", + "solver", + "vehicle routing problem", +] +license = { file = "LICENSE" } +maintainers = [ + { email = "tech@nextmv.io", name = "Nextmv" } +] +name = "nextmv" +readme = "README.md" +requires-python = ">=3.10" +version = "0.1.0.dev3" [project.urls] Homepage = "https://www.nextmv.io" Documentation = "https://www.nextmv.io/docs" -Repository = "https://github.com/nextmv-io/sdk-python" +Repository = "https://github.com/nextmv-io/nextmv-py" [tool.ruff] target-version = "py312" diff --git a/requirements.txt b/requirements.txt index 263bed1..6dc7bc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -pydantic==2.5.2 -requests==2.31.0 -ruff==0.1.7 -setuptools==69.0.2 -wheel==0.42.0 +build>=1.0.3 +pydantic>=2.5.2 +requests>=2.31.0 +ruff>=0.1.7 +twine>=4.0.2