-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nextmv-io/feature/eng-4277-create-workflow…
…-for-publishingdistributing-the-package ENG-4277 Modify workflow for PyPI and TestPYPI
- Loading branch information
Showing
6 changed files
with
141 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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=<your-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[email protected]" } | ||
{ email = "[email protected]", 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 = "[email protected]", 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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |