Skip to content

Commit

Permalink
Merge pull request #167 from PrimozGodec/reusable-workflows
Browse files Browse the repository at this point in the history
CI - Reusable workflows
  • Loading branch information
janezd committed Feb 9, 2023
2 parents d9f4565 + 62e73c6 commit 5622f33
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 116 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
uses: biolab/orange-ci-cd/.github/workflows/rebase-addons.yml@master
secrets: inherit
101 changes: 2 additions & 99 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,102 +9,5 @@ on:
- master

jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 15
name: ${{ matrix.name }} (${{ matrix.os }}, ${{ matrix.python-version }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15, windows-2019]
python-version: [3.7, 3.8, 3.9]
tox_env: [py-orange-released]
experimental: [false]
name: [Released]
include:
- os: windows-latest
python-version: 3.8
tox_env: py-orange-released
experimental: true
name: Windows10
- os: macos-11.0
python-version: 3.8
tox_env: py-orange-released
experimental: true
name: Big Sur

- os: windows-2019
python-version: 3.7
tox_env: py-orange-oldest
experimental: false
name: Oldest
- os: macos-10.15
python-version: 3.7
tox_env: py-orange-oldest
name: Oldest
experimental: false
- os: ubuntu-18.04
python-version: 3.7
tox_env: py-orange-oldest
name: Oldest
experimental: false

- os: windows-2019
python-version: 3.8
tox_env: py-orange-latest
experimental: false
name: Latest
- os: macos-10.15
python-version: 3.8
tox_env: py-orange-latest
experimental: false
name: Latest
- os: ubuntu-18.04
python-version: 3.8
tox_env: py-orange-latest
experimental: false
name: Latest

- os: windows-2019
python-version: 3.9
tox_env: py-orange-latest
experimental: false
name: Latest
- os: macos-10.15
python-version: 3.9
tox_env: py-orange-latest
experimental: false
name: Latest
- os: ubuntu-18.04
python-version: 3.9
tox_env: py-orange-latest
experimental: false
name: Latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Test with Tox
run: |
tox -e ${{ matrix.tox_env }}
env:
QT_QPA_PLATFORM: offscreen

- name: Upload code coverage
if: |
matrix.python-version == '3.8' &&
matrix.os == 'ubuntu-18.04' &&
matrix.tox_env == 'py-orange-released'
run: |
pip install codecov
codecov
test:
uses: biolab/orange-ci-cd/.github/workflows/test-addons.yml@master
19 changes: 19 additions & 0 deletions orangecontrib/geo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
from os.path import join, dirname
from Orange.data.table import dataset_dirs
from Orange.data import Table


dataset_dirs.insert(0, join(dirname(__file__), "datasets"))
del join, dirname, dataset_dirs


# Remove this when we require Orange 3.34
if not hasattr(Table, "get_column"):
import scipy.sparse as sp
import numpy as np

def get_column(self, column):
col, _ = self.get_column_view(column)
if sp.issparse(col):
col = col.toarray().reshape(-1)
if self.domain[column].is_primitive():
col = col.astype(np.float64)
return col

Table.get_column = get_column
17 changes: 17 additions & 0 deletions orangecontrib/geo/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from unittest import TestCase

import numpy as np
Expand Down Expand Up @@ -96,3 +97,19 @@ def attrs_for(*attrs, x=None):
self.assertEqual(attrs_for(d1, c1, c2, lon), (c1, c1))
self.assertEqual(attrs_for(d1, lon, c1, c2), (lon, lon))
self.assertEqual(attrs_for(d1, c3, c2, c1), (c3, c3))


class TestDeprecations(unittest.TestCase):
def test_remove_get_column_workaround(self):
"""
When this tests start to fail:
1. remove this test
2. set minimum version of Orange to 3.34 if not set yet
3. remove workaround from __inint__.py
"""
from datetime import datetime
self.assertLess(datetime.today(), datetime(2024, 1, 1))


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion orangecontrib/geo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def find_lat_lon(data, filter_hidden=False):
def max_in_col(attr):
if not data:
return 0
return np.nanmax(np.abs(data.get_column_view(attr)[0].astype(float)))
return np.nanmax(np.abs(data.get_column(attr).astype(float)))

if len(cont_vars) == 2:
if lat_attr is not None:
Expand Down
5 changes: 2 additions & 3 deletions orangecontrib/geo/widgets/owchoropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,7 @@ def get_regions(self, lat_attr, lon_attr, admin):
dict of region ids matched to their additional info,
dict of region ids matched to their polygon
"""
latlon = np.c_[self.data.get_column_view(lat_attr)[0],
self.data.get_column_view(lon_attr)[0]]
latlon = np.c_[self.data.get_column(lat_attr), self.data.get_column(lon_attr)]
region_info = latlon2region(latlon, admin)
ids = np.array([region.get('_id') for region in region_info])
region_info = {info.get('_id'): info for info in region_info}
Expand All @@ -931,7 +930,7 @@ def get_grouped(self, lat_attr, lon_attr, admin, attr, agg_func):
Series of aggregated values
"""
if attr is not None:
data = self.data.get_column_view(attr)[0]
data = self.data.get_column(attr)
else:
data = np.ones(len(self.data))

Expand Down
6 changes: 3 additions & 3 deletions orangecontrib/geo/widgets/owgeocoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def decode(self):
self.lat_attr not in self.data.domain or
self.lon_attr not in self.data.domain):
return None
latlon = np.c_[self.data.get_column_view(self.lat_attr)[0],
self.data.get_column_view(self.lon_attr)[0]]
latlon = np.c_[self.data.get_column(self.lat_attr),
self.data.get_column(self.lon_attr)]
assert isinstance(self.admin, int)
with self.progressBar(2) as progress:
progress.advance()
Expand Down Expand Up @@ -280,7 +280,7 @@ def _get_data_values(self):
if self.data is None:
return None

values = self.data.get_column_view(self.str_attr)[0]
values = self.data.get_column(self.str_attr)
# no comment
if self.str_attr.is_discrete:
values = np.array(self.str_attr.values)[values.astype(np.int16)].astype(str)
Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/geo/widgets/owgeotransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def __init__(self, transformer, var_lat, var_lon):
self.var_lat, self.var_lon = var_lat, var_lon

def __call__(self, data):
latitude = data.get_column_view(self.var_lat)[0]
longitude = data.get_column_view(self.var_lon)[0]
latitude = data.get_column(self.var_lat)
longitude = data.get_column(self.var_lon)
coords = tuple(
zip(*self.transformer.itransform(zip(latitude, longitude))))
return coords
Expand Down
2 changes: 1 addition & 1 deletion orangecontrib/geo/widgets/owmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _add_controls(self):
lat_lon_box = gui.vBox(self.controlArea, box="Layout", spacing=0)
options = dict(
labelWidth=75, orientation=Qt.Horizontal, sendSelectedValue=True,
valueType=str, contentsLength=14
contentsLength=14
)

gui.comboBox(lat_lon_box, self, 'graph.tile_provider_key', label='Map:',
Expand Down
7 changes: 6 additions & 1 deletion orangecontrib/geo/widgets/tests/test_owchoropleth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from unittest.mock import patch
import numpy as np

Expand Down Expand Up @@ -118,4 +119,8 @@ def test_no_data(self):
with self.data.unlocked():
self.data.X[:] = np.nan

self.send_signal(self.widget.Inputs.data, self.data)
self.send_signal(self.widget.Inputs.data, self.data)


if __name__ == "__main__":
unittest.main()
3 changes: 0 additions & 3 deletions orangecontrib/geo/widgets/tests/test_owgeocoding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# pylint: disable=protected-access
import unittest
import numpy as np
import pandas as pd

from Orange.data import Table, Domain, DiscreteVariable
from Orange.widgets.tests.base import WidgetTest
Expand Down Expand Up @@ -81,4 +79,3 @@ def test_minimum_size(self):

if __name__ == "__main__":
unittest.main()

6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{37,38,39}-orange-{oldest, latest, released}
orange-{oldest, latest, released}
skip_missing_interpreters = true
isolated_build = true

Expand All @@ -20,8 +20,8 @@ setenv =
COVERAGE_FILE = {toxinidir}/.coverage
COVERAGE_RCFILE = {toxinidir}/.coveragerc
deps =
pyqt5==5.12.*
pyqtwebengine==5.12.*
{env:PYQT_PYPI_NAME:PyQt5}=={env:PYQT_PYPI_VERSION:5.15.*}
{env:WEBENGINE_PYPI_NAME:PyQtWebEngine}=={env:WEBENGINE_PYPI_VERSION:5.15.*}
oldest: scikit-learn~=0.22.0
oldest: orange3==3.25.0
# Use newer canvas-core and widget-base to avoid segfaults on windows
Expand Down

0 comments on commit 5622f33

Please sign in to comment.