From 9a71adeae08d29af6db4c58e0865551729e8d4f0 Mon Sep 17 00:00:00 2001 From: olgavrou Date: Wed, 25 Oct 2023 06:56:24 -0400 Subject: [PATCH] add pypi release workflow and fixes --- .github/workflows/pypi_release.yml | 38 +++++++++++++++++++++++ README.md | 2 +- notebooks/news_recommendation.ipynb | 2 +- notebooks/prompt_variable_injection.ipynb | 2 +- setup.py | 13 ++++++-- tests/unit_tests/pytest.ini | 3 -- version.txt | 1 + 7 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pypi_release.yml delete mode 100644 tests/unit_tests/pytest.ini create mode 100644 version.txt diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 0000000..3aedb13 --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -0,0 +1,38 @@ +name: pypi-release + +on: + release: + types: [published] + +jobs: + deploy: + strategy: + matrix: + os: ['ubuntu-latest'] + python-version: [3.10] + + runs-on: ${{ matrix.os }} + environment: + name: Release-PyPi + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: | + pip install twine + python setup.py sdist bdist_wheel + + - name: Check wheels + run: twine check dist/* + + - name: Upload to TestPyPi + uses: pypa/gh-action-pypi-publish@v1.6.4 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Upload to PyPi + uses: pypa/gh-action-pypi-publish@v1.6.4 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/README.md b/README.md index cb245ab..8408944 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The beauty of `learn_to_pick` is its flexibility. Whether you're a fan of Vowpal ## Installation -`pip install .` +`pip install learn-to-pick` ## Basic Usage diff --git a/notebooks/news_recommendation.ipynb b/notebooks/news_recommendation.ipynb index ad691af..c38e4c6 100644 --- a/notebooks/news_recommendation.ipynb +++ b/notebooks/news_recommendation.ipynb @@ -96,7 +96,7 @@ "outputs": [], "source": [ "picker = learn_to_pick.PickBest.create(metrics_step=20, metrics_window_size=20, selection_scorer=CustomSelectionScorer())\n", - "random_picker = learn_to_pick.PickBest.create(metrics_step=20, metrics_window_size=20, policy=learn_to_pick.PickBestRandomPolicy, selection_scorer=CustomSelectionScorer())" + "random_picker = learn_to_pick.PickBest.create(metrics_step=20, metrics_window_size=20, policy=learn_to_pick.PickBestRandomPolicy(), selection_scorer=CustomSelectionScorer())" ] }, { diff --git a/notebooks/prompt_variable_injection.ipynb b/notebooks/prompt_variable_injection.ipynb index c03f94c..f7b5be8 100644 --- a/notebooks/prompt_variable_injection.ipynb +++ b/notebooks/prompt_variable_injection.ipynb @@ -126,7 +126,7 @@ " preference = learn_to_pick.BasedOn([\"Vegetarian\", \"regular dairy is ok\"]),\n", ")\n", "\n", - "picked_meal = response[\"picked\"][0][\"meal\"]" + "picked_meal = response[\"picked\"][\"meal\"]" ] }, { diff --git a/setup.py b/setup.py index 9c7dee1..10a5b7c 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,15 @@ from setuptools import setup, find_packages +import os + +with open("README.md", "r", encoding="UTF-8") as fh: + long_description = fh.read() + +with open("version.txt", "r", encoding="utf-8") as version_file: + version = version_file.read().strip() setup( name="learn_to_pick", - version="0.1", + version=version, install_requires=[ "numpy", "pandas", @@ -14,7 +21,9 @@ ], extras_require={"dev": ["pytest", "black==23.10.0"]}, author="VowpalWabbit", - description="", + description="a python library for online learning RL loops, specialized for Contextual Bandit scenarios.", + long_description_content_type="text/markdown", + long_description=long_description, packages=find_packages(where="src"), package_dir={"": "src"}, url="https://github.com/VowpalWabbit/learn_to_pick", diff --git a/tests/unit_tests/pytest.ini b/tests/unit_tests/pytest.ini deleted file mode 100644 index a171c31..0000000 --- a/tests/unit_tests/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -markers = - requires(name): Mark test to run only when the specified requirement is met. diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.0.1