Skip to content

Commit

Permalink
Merge pull request #164 from pescadores/2024-fixings
Browse files Browse the repository at this point in the history
2024 fixings
  • Loading branch information
bmcfee authored Jan 30, 2024
2 parents d1ed01b + 639a282 commit e4f6b68
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 207 deletions.
17 changes: 17 additions & 0 deletions .github/environment-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pescador-dev
channels:
- conda-forge
- defaults
dependencies:
# required
- pip
- six>=1.8
- pyzmq>=18.0
- decorator>=4.0

# optional, but required for testing
- pytest
- pytest-cov
- pytest-timeout>=1.2
- coverage
- scipy
17 changes: 17 additions & 0 deletions .github/environment-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pescador-dev
channels:
- conda-forge
- defaults
dependencies:
# required
- pip
- six~=1.8
- pyzmq~=18.0
- decorator~=4.0

# optional, but required for testing
- pytest
- pytest-cov
- pytest-timeout>=1.2
- coverage
- scipy
110 changes: 110 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: True

jobs:
test:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.7"
envfile: ".github/environment-minimal.yml"
channel-priority: "flexible"
name: "Minimal dependencies"

- os: ubuntu-latest
python-version: "3.8"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

- os: ubuntu-latest
python-version: "3.9"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

- os: ubuntu-latest
python-version: "3.10"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

- os: ubuntu-latest
python-version: "3.11"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

- os: macos-latest
python-version: "3.11"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

- os: windows-latest
python-version: "3.11"
channel-priority: "strict"
envfile: ".github/environment-ci.yml"

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Cache conda
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles( matrix.envfile ) }}

- name: Install Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
add-pip-as-python-dependency: true
auto-activate-base: false
activate-environment: test
channel-priority: ${{ matrix.channel-priority }}
environment-file: ${{ matrix.envfile }}
use-only-tar-bz2: false # IMPORTANT: This needs to be set for caching to work properly!

- name: Conda info
shell: bash -l {0}
run: |
conda info -a
conda list
- name: Install pescador
shell: bash -l {0}
run: python -m pip install --upgrade-strategy only-if-needed -e .[tests]

- name: Run pytest
shell: bash -l {0}
run: pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/reports/
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .travis_dependencies.sh

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pescador
========
[![PyPI](https://img.shields.io/pypi/v/pescador.svg)](https://pypi.python.org/pypi/pescador)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/pescador/badges/version.svg)](https://anaconda.org/conda-forge/pescador)
[![Build Status](https://travis-ci.org/pescadores/pescador.svg?branch=master)](https://travis-ci.org/pescadores/pescador)
[![Coverage Status](https://coveralls.io/repos/pescadores/pescador/badge.svg)](https://coveralls.io/r/pescadores/pescador)
[![Build Status](https://github.com/pescadores/pescador/actions/workflows/ci.yml/badge.svg)](https://github.com/pescadores/pescador/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/pescadores/pescador/graph/badge.svg?token=aCgfizw6O5)](https://codecov.io/gh/pescadores/pescador)
[![Documentation Status](https://readthedocs.org/projects/pescador/badge/?version=latest)](https://readthedocs.org/projects/pescador/?badge=latest)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.400700.svg)](https://doi.org/10.5281/zenodo.400700)

Expand Down
4 changes: 2 additions & 2 deletions pescador/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# -*- coding: utf-8 -*-
"""Version info"""

short_version = '2.1'
version = '2.1.0'
short_version = '3.0'
version = '3.0.0-dev'
33 changes: 4 additions & 29 deletions pescador/zmq_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,19 @@
import multiprocessing as mp
import zmq
import numpy as np
import six
import sys
import warnings

try:
import ujson as json
except ImportError:
import json

try:
# joblib <= 0.9.4
from joblib.parallel import SafeFunction
except ImportError:
# joblib >= 0.10.0
from joblib._parallel_backends import SafeFunction

from .core import Streamer
from .exceptions import DataError


__all__ = ['ZMQStreamer']


# A hack to support buffers in py3
if six.PY3:
buffer = memoryview


def zmq_send_data(socket, data, flags=0, copy=True, track=False):
"""Send data, e.g. {key: np.ndarray}, with metadata"""

Expand Down Expand Up @@ -82,12 +67,9 @@ def zmq_recv_data(socket, flags=0, copy=True, track=False):
raise StopIteration

for header, payload in zip(headers, msg[1:]):
data[header['key']] = np.frombuffer(buffer(payload),
data[header['key']] = np.frombuffer(memoryview(payload),
dtype=header['dtype'])
data[header['key']].shape = header['shape']
if six.PY2:
# Legacy python won't let us preserve alignment, skip this step
continue
data[header['key']].flags['ALIGNED'] = header['aligned']

return data
Expand Down Expand Up @@ -178,10 +160,6 @@ def iterate(self, max_iter=None):
"""
context = zmq.Context()

if six.PY2:
warnings.warn('zmq_stream cannot preserve numpy array alignment '
'in Python 2', RuntimeWarning)

try:
socket = context.socket(zmq.PAIR)

Expand All @@ -191,7 +169,7 @@ def iterate(self, max_iter=None):
max_tries=self.max_tries)
terminate = mp.Event()

worker = mp.Process(target=SafeFunction(zmq_worker),
worker = mp.Process(target=zmq_worker,
args=[port, self.streamer, terminate],
kwargs=dict(copy=self.copy,
max_iter=max_iter))
Expand All @@ -206,13 +184,10 @@ def iterate(self, max_iter=None):
except StopIteration:
pass

except:
# pylint: disable-msg=W0702
six.reraise(*sys.exc_info())

finally:
terminate.set()
worker.join(self.timeout)
if worker.is_alive():
worker.join(self.timeout)
if worker.is_alive():
worker.terminate()
context.destroy()
46 changes: 45 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
[tool:pytest]
addopts = --cov-report term-missing --cov pescador
addopts = --cov-report term-missing --cov pescador --cov-report=xml

[metadata]
name = pescador
version = attr: pescador.version.version
description = Multiplex generators for incremental learning
author = Pescador developers
author_email = [email protected]
url = https://github.com/pescadores/pescador
download_url = https://github.com/pescadores/pescador/releases
long_description = Multiplex generators for incremental learning
license = ISC
python_requires = ">=3.7"
classifiers =
License :: OSI Approved :: ISC License (ISCL)
Programming Language :: Python
Development Status :: 3 - Alpha
Intended Audience :: Developers
Topic :: Multimedia :: Sound/Audio :: Analysis
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

[options]
packages = find:
keywords = machine learning
install_requires =
six >= 1.8
pyzmq >= 18.0
numpy >= 1.9
decorator >= 4.0

[options.extras_require]
docs =
numpydoc >= 0.6
sphinx-gallery >= 0.1.10
tests =
pytest
pytest-timeout>=1.2
pytest-cov
scipy

Loading

0 comments on commit e4f6b68

Please sign in to comment.