Skip to content

Commit 5210b80

Browse files
author
gerrymanoim
authored
BLD/BUG: GH actions (#293)
* BLD: GH actions for tests * BUG: Fix series comparison * BUG: Fix tz old vs new conversion issues * BLD: Automatic builds and publish * BLD: Bump the version
1 parent fcf6cd0 commit 5210b80

File tree

13 files changed

+612
-526
lines changed

13 files changed

+612
-526
lines changed

.github/release-drafter-config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name-template: 'v$NEXT_PATCH_VERSION 🌈'
2+
tag-template: 'v$NEXT_PATCH_VERSION'
3+
template: |
4+
## What’s Changed
5+
6+
$CHANGES

.github/workflows/main.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
python-version: [2.7, 3.5, 3.7, 3.8]
20+
include:
21+
- python-version: 2.7
22+
pandas: 0.18.1
23+
numpy: 1.11.3
24+
- python-version: 3.5
25+
pandas: 0.18.1
26+
numpy: 1.11.3
27+
- python-version: 3.7
28+
pandas: 1.0.1
29+
numpy: 1.18.1
30+
- python-version: 3.8
31+
pandas: 1.0.1
32+
numpy: 1.18.1
33+
34+
steps:
35+
- uses: actions/checkout@v1
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: actions/setup-python@v1
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- uses: actions/cache@v1
41+
with:
42+
path: ~/.cache/pip
43+
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pandas }}-${{ matrix.numpy }}-pip-${{ hashFiles('**/setup.py') }}
44+
- name: Install dependencies
45+
env:
46+
PYTHONWARNINGS: ignore:DEPRECATION::pip._internal.cli.base_command
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install pandas==${{ matrix.pandas }} numpy==${{ matrix.numpy }}
50+
pip install -e .[test]
51+
- name: Lint with flake8
52+
run: |
53+
flake8
54+
- name: Run the tests
55+
run: |
56+
pytest

.github/workflows/master-merge.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: On Master Merge
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
draft-release-publish:
10+
name: Draft a new release
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Drafts your next Release notes as Pull Requests are merged into "master"
14+
- uses: release-drafter/release-drafter@v5
15+
with:
16+
config-name: release-drafter-config.yml
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Python 🐍 distributions 📦 to PyPI
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
build-n-publish:
8+
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
9+
runs-on: ubuntu-18.04
10+
steps:
11+
- uses: actions/checkout@master
12+
- name: Set up Python 3.7
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: 3.7
16+
17+
- name: Build sdist
18+
run: python setup.py sdist
19+
20+
- name: Publish distribution 📦 to Test PyPI
21+
uses: pypa/gh-action-pypi-publish@master
22+
with:
23+
password: ${{ secrets.test_pypi_password }}
24+
repository_url: https://test.pypi.org/legacy/
25+
26+
- name: Install from test and test running
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install --extra-index-url https://test.pypi.org/simple qgrid
30+
python -c 'import qgrid;print(qgrid.__version__)'
31+
pip uninstall -y qgrid
32+
33+
- name: Publish distribution 📦 to PyPI
34+
uses: pypa/gh-action-pypi-publish@master
35+
with:
36+
password: ${{ secrets.pypi_password }}
37+
38+
- name: Install and test running
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install --extra-index-url qgrid
42+
python -c 'import qgrid;print(qgrid.__version__)'

qgrid/__init__.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ._version import version_info, __version__
1+
from ._version import version_info, __version__ # noqa F401
22

33
from .grid import (
44
enable,
@@ -9,25 +9,29 @@
99
set_grid_option,
1010
show_grid,
1111
QgridWidget,
12-
QGridWidget
12+
QGridWidget,
1313
)
1414

15+
1516
def _jupyter_nbextension_paths():
16-
return [{
17-
'section': 'notebook',
18-
'src': 'static',
19-
'dest': 'qgrid',
20-
'require': 'qgrid/extension'
21-
}]
17+
return [
18+
{
19+
"section": "notebook",
20+
"src": "static",
21+
"dest": "qgrid",
22+
"require": "qgrid/extension",
23+
}
24+
]
25+
2226

2327
__all__ = [
24-
'enable',
25-
'disable',
26-
'set_defaults',
27-
'on',
28-
'off',
29-
'set_grid_option',
30-
'show_grid',
31-
'QgridWidget',
32-
'QGridWidget'
28+
"enable",
29+
"disable",
30+
"set_defaults",
31+
"on",
32+
"off",
33+
"set_grid_option",
34+
"show_grid",
35+
"QgridWidget",
36+
"QGridWidget",
3337
]

qgrid/_version.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
version_info = (1, 2, 0, 'final')
1+
version_info = (1, 3, 0, "final")
22

3-
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
3+
_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}
44

5-
__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
6-
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
5+
__version__ = "%s.%s.%s%s" % (
6+
version_info[0],
7+
version_info[1],
8+
version_info[2],
9+
""
10+
if version_info[3] == "final"
11+
else _specifier_[version_info[3]] + str(version_info[4]),
12+
)

qgrid/grid.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def _update_table(self,
856856
to_index = max(self._viewport_range[0] + PAGE_SIZE, 0)
857857
new_df_range = (from_index, to_index)
858858

859-
if triggered_by is 'viewport_changed' and \
859+
if triggered_by == 'viewport_changed' and \
860860
self._df_range == new_df_range:
861861
return
862862

@@ -1431,12 +1431,15 @@ def _handle_qgrid_msg_helper(self, content):
14311431
try:
14321432
location = (self._df.index[content['row_index']],
14331433
content['column'])
1434+
old_value = self._df.loc[location]
14341435

14351436
val_to_set = content['value']
14361437
if col_info['type'] == 'datetime':
14371438
val_to_set = pd.to_datetime(val_to_set)
1439+
# pandas > 18.0 compat
1440+
if old_value.tz != val_to_set.tz:
1441+
val_to_set = val_to_set.tz_convert(tz=old_value.tz)
14381442

1439-
old_value = self._df.loc[location]
14401443
self._df.loc[location] = val_to_set
14411444

14421445
query = self._unfiltered_df[self._index_col_name] == \

qgrid/pd_json/json.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
458458
try:
459459
dtype = np.dtype(dtype)
460460
return data.astype(dtype), True
461-
except:
461+
except Exception:
462462
return data, False
463463

464464
if convert_dates:
@@ -474,7 +474,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
474474
try:
475475
data = data.astype('float64')
476476
result = True
477-
except:
477+
except Exception:
478478
pass
479479

480480
if data.dtype.kind == 'f':
@@ -485,7 +485,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
485485
try:
486486
data = data.astype('float64')
487487
result = True
488-
except:
488+
except Exception:
489489
pass
490490

491491
# do't coerce 0-len data
@@ -497,7 +497,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
497497
if (new_data == data).all():
498498
data = new_data
499499
result = True
500-
except:
500+
except Exception:
501501
pass
502502

503503
# coerce ints to 64
@@ -507,7 +507,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
507507
try:
508508
data = data.astype('int64')
509509
result = True
510-
except:
510+
except Exception:
511511
pass
512512

513513
return data, result
@@ -526,7 +526,7 @@ def _try_convert_to_date(self, data):
526526
if new_data.dtype == 'object':
527527
try:
528528
new_data = data.astype('int64')
529-
except:
529+
except Exception:
530530
pass
531531

532532
# ignore numbers that are out of range
@@ -543,7 +543,7 @@ def _try_convert_to_date(self, data):
543543
unit=date_unit)
544544
except ValueError:
545545
continue
546-
except:
546+
except Exception:
547547
break
548548
return new_data, True
549549
return data, False
@@ -649,12 +649,9 @@ def _parse_no_numpy(self):
649649
self.obj = DataFrame(
650650
loads(json, precise_float=self.precise_float), dtype=None)
651651

652-
def _process_converter(self, f, filt=None):
652+
def _process_converter(self, f, filt=lambda col, c: True):
653653
""" take a conversion function and possibly recreate the frame """
654654

655-
if filt is None:
656-
filt = lambda col, c: True
657-
658655
needs_new_obj = False
659656
new_obj = dict()
660657
for i, (col, c) in enumerate(self.obj.iteritems()):

qgrid/pd_json/normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _pull_field(js, spec):
171171

172172
return result
173173

174-
if isinstance(data, list) and len(data) is 0:
174+
if isinstance(data, list) and len(data) == 0:
175175
return DataFrame()
176176

177177
# A bit of a hackjob

qgrid/tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

0 commit comments

Comments
 (0)