Skip to content

Commit

Permalink
Merge pull request #191 from kiudee/pytorch-migration
Browse files Browse the repository at this point in the history
Migrate to PyTorch
  • Loading branch information
kiudee authored Apr 13, 2021
2 parents 1aee3c0 + 7c1f922 commit 639473b
Show file tree
Hide file tree
Showing 114 changed files with 3,686 additions and 10,869 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .github/workflows/release.yml
name: Release
on:
release:
types: [published]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: '3.8'
architecture: x64
- run: pip install nox==2020.12.31
- run: pip install nox-poetry==0.8.4
- run: pip install poetry==1.1.4
- run: nox
- run: poetry build
- run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
90 changes: 90 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Tests
on:
- push
- pull_request
jobs:
tests:
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
include:
- { python-version: 3.8, os: ubuntu-latest, session: "pre-commit" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
- { python-version: 3.8, os: ubuntu-latest, session: "docs-build" }

name: "${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}"
env:
NOXSESSION: "${{ matrix.session }}"
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: pip install nox==2020.12.31
- run: pip install nox-poetry==0.8.4
- run: pip install poetry==1.1.4
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/[email protected]
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: "${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}"
restore-keys: |
"${{ steps.pre-commit-cache.outputs.result }}-"
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/[email protected]"
with:
name: coverage-data
path: ".coverage.*"


coverage:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Set up Python 3.8
uses: actions/[email protected]
with:
python-version: 3.8

- run: pip install nox==2020.12.31
- run: pip install nox-poetry==0.8.4
- run: pip install poetry==1.1.4

- name: Download coverage data
uses: actions/[email protected]
with:
name: coverage-data

- name: Combine coverage data and display human readable report
run: |
nox --force-color --session=coverage
- name: Create coverage report
run: |
nox --force-color --session=coverage -- xml
- name: Upload coverage report
uses: codecov/[email protected]
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/PyCQA/doc8
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sphinx:
configuration: docs/conf.py

python:
version: 3.7
version: 3.8
install:
- method: pip
path: .
Expand Down
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- 3.7.9 # Pinned since tensorflow 1.x is not available for python > 3.7
- 3.8

cache:
directories:
Expand All @@ -23,18 +23,16 @@ stages:
jobs:
fast_finish: true
include:
- python: 3.7.9
- python: 3.8
env: TOXENV=test1
- python: 3.7.9
- python: 3.8
env: TOXENV=test2
- python: 3.7.9
- python: 3.8
env: TOXENV=test3
- python: 3.7.9
env: TOXENV=test4
- python: 3.7.9
- python: 3.8
env: TOXENV=lint
- stage: docs
python: 3.7.9
python: 3.8
env: TOXENV=docs

before_deploy:
Expand All @@ -47,6 +45,6 @@ deploy:
script: poetry publish -v --build
on:
tags: true
python: 3.7.9
python: 3.8
repo: kiudee/cs-ranking
branch: master
12 changes: 3 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,9 @@ Deploying
~~~~~~~~~

Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run

.. code-block:: bash
$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags
The new version will automatically be released on PyPi.
Then click on `"Draft a new release"`__ at the GitHub repository.
GitHub Actions will ensure that the package is uploaded to PyPI.

__ https://github.com/kiudee/cs-ranking/releases/new

.. _poetry: https://python-poetry.org/
17 changes: 16 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
History
=======

Unreleased
2.0.0 (Unreleased)
------------------

* The library has been migrated to pytorch. This is a breaking change. You will
likely need to adapt to this new version if you have been using estimators
from version 1.x.

* The RankNet and CmpNet estimators are now trained with a loss that applies to
the whole result (the general/discrete choice or ranking). They were
previously trained on object pairs with different loss functions.

* Behavior and default parameters of the estimators may differ from the
previous versions. For example the default activation for CmpNet and RankNet
is now SELU instead of ReLU.

1.3.0 (Unreleased)
------------------

* We no longer override any of the defaults of our default optimizer (SGD). In
Expand Down
25 changes: 17 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
|Build Status| |Coverage| |Binder|
|Coverage| |Binder|

****
NOTE
****

This library has recently been migrated from tensorflow to PyTorch. The 2.0
version marks a breaking change. Some of the previous functionality is now
unavailable and some classes behave differently. You can use the latest 1.x
release if you are looking for the tensorflow based estimators.

*******
CS-Rank
*******

CS-Rank is a Python package for context-sensitive ranking and choice
algorithms.

Expand All @@ -27,9 +37,6 @@ setting:
* RankNetDiscreteChoiceFunction
* PairwiseSVMDiscreteChoiceFunction

Check out our `interactive notebooks`_ to quickly find out what our package can
do.


Getting started
===============
Expand Down Expand Up @@ -73,7 +80,7 @@ Another option is to clone the repository and install CS-Rank using::

Dependencies
------------
CS-Rank depends on Tensorflow, Keras, NumPy, SciPy, matplotlib, scikit-learn,
CS-Rank depends on PyTorch, skorch, NumPy, SciPy, matplotlib, scikit-learn,
joblib and tqdm. For data processing and generation you will
also need PyGMO, H5Py and pandas.

Expand Down Expand Up @@ -111,10 +118,12 @@ License
:target: https://mybinder.org/v2/gh/kiudee/cs-ranking/master?filepath=docs%2Fnotebooks

.. |Coverage| image:: https://codecov.io/gh/kiudee/cs-ranking/branch/master/graph/badge.svg
:target: https://codecov.io/gh/kiudee/cs-ranking
:target: https://codecov.io/gh/kiudee/cs-ranking

.. |Build Status| image:: https://travis-ci.org/kiudee/cs-ranking.svg?branch=master
:target: https://travis-ci.org/kiudee/cs-ranking
..
|Build Status| image:: https://img.shields.io/github/workflow/status/kiudee/cs-ranking/tests
:target: https://github.com/kiudee/cs-ranking/actions
:alt: GitHub Workflow Status

.. _interactive notebooks: https://mybinder.org/v2/gh/kiudee/cs-ranking/master?filepath=docs%2Fnotebooks
Expand Down
10 changes: 6 additions & 4 deletions csrank/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
__version__ = "1.2.1"

# We should re-evaluate if we really want to re-export everything here and then
# use __all__ properly.
from importlib.metadata import version

from .choicefunction import * # noqa
from .core import * # noqa
from .dataset_reader import * # noqa
from .discretechoice import * # noqa
from .objectranking import * # noqa

# We should re-evaluate if we really want to re-export everything here and then
# use __all__ properly.

__version__ = version(__name__)
Loading

0 comments on commit 639473b

Please sign in to comment.