Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flake fixes pt4 #127

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build Documentation

on:
push:
branches:
- main
release:

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: build
auto-update-conda: true

- name: install requirements
run: >-
conda install -n build -c conda-forge
--file requirements/build.txt
--file requirements/run.txt
--file requirements/docs.txt
--quiet --yes

- name: install the package
run: python -m pip install . --no-deps

- name: build documents
run: make -C doc html

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/build/html
53 changes: 53 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- main
- CI
pull_request:
workflow_dispatch:

jobs:
miniconda:
name: Miniconda ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
steps:
- name: check out diffpy.pdfgui
uses: actions/checkout@v3
with:
repository: diffpy/diffpy.pdfgui
path: .
fetch-depth: 0 # avoid shallow clone with no tags

- name: Install Mamba
run: |
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh" -O mambaforge.sh
bash mambaforge.sh -b -p $HOME/mambaforge
echo "$HOME/mambaforge/bin" >> $GITHUB_PATH
source $HOME/mambaforge/etc/profile.d/conda.sh
conda init bash

- name: Create conda environment
run: |
source $HOME/mambaforge/etc/profile.d/conda.sh
conda create -n test_env python=3.12 xonsh regolith -c conda-forge -y
conda activate test_env
pip install case_insensitive_dict

- name: Install dependencies
run: |
source $HOME/mambaforge/etc/profile.d/conda.sh
conda activate test_env
mamba install --file requirements/run.txt
mamba install --file requirements/test.txt
pip install -e .

- name: Use Xvfb Action
uses: GabrielBB/xvfb-action@v1
with:
run: |
bash -c "source $HOME/mambaforge/etc/profile.d/conda.sh && conda activate test_env && python -m run_tests.py"
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit

on:
pull_request:
push:
workflow_dispatch:

jobs:
pre-commit:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
File renamed without changes.
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml → conda-recipe/meta.suppress_yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test:
# entry points work.


# You can also put a file called run_test.py in the recipe that will be run
# You can also put a file called dont_run.py in the recipe that will be run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed but these hacks will be removed later so don't worry...

# at test time.

# requires:
Expand Down
6 changes: 6 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: diffpy.pdfgui
channels:
- conda-forge
dependencies:
- python=3
- pip
2 changes: 1 addition & 1 deletion requirements/run.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy
numpy==1.26
wxpython
diffpy.pdffit2
diffpy.utils
Expand Down
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pytest
freezegun
coverage
codecov
5 changes: 5 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python

import diffpy.pdfgui.tests

assert diffpy.pdfgui.tests.testdeps().wasSuccessful()
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2009 Trustees of the Columbia University
# (c) 2009-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/structureviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2009 Trustees of the Columbia University
# (c) 2009-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
4 changes: 3 additions & 1 deletion src/diffpy/pdfgui/gui/aboutdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# PDFgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2006 trustees of the Michigan State University.
# (c) 2024 trustees of the Columbia University in the City
# of New York
# All rights reserved.
#
# File coded by: Dmitriy Bryndin
Expand Down Expand Up @@ -233,7 +235,7 @@ def onColumbiaLogo(self, event): # wxGlade: DialogAbout.<event_handler>

# end of class DialogAbout

##### testing code ###########################################################
# #### testing code ###########################################################

if __name__ == "__main__":
app = wx.App()
Expand Down
1 change: 1 addition & 0 deletions src/diffpy/pdfgui/gui/adddatapanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# PDFgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2006 trustees of the Michigan State University.
# (c) 2024 trustees of the Columbia University in the City
# All rights reserved.
#
# File coded by: Chris Farrow
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/gui/errorwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _f(*args, **kwargs):
return rvpass

# Everything else
except:
except Exception:
if pdfguiglobals.dbopts.pythondebugger:
import pdb

Expand Down
18 changes: 9 additions & 9 deletions src/diffpy/pdfgui/gui/fittree.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ def AddFit(self, fitname="Fit 1", cdata=None, paste=False):
cdata = self.control.paste(cdata, None, fitname, pos)
self.SetControlData(newfit, cdata)
return newfit
except:
except Exception:
self.Delete(newfit)
raise
raise Exception
return

def AddPhase(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None):
Expand Down Expand Up @@ -427,9 +427,9 @@ def AddPhase(self, node, label, insertafter=None, filename=None, makedata=True,
elif cdata is not None:
self.control.paste(cdata, pdata, label, pos)
return newphase
except:
except Exception:
self.Delete(newphase)
raise
raise Exception
return

def AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True, cdata=None):
Expand Down Expand Up @@ -492,9 +492,9 @@ def AddDataSet(self, node, label, insertafter=None, filename=None, makedata=True
elif cdata is not None:
self.control.paste(cdata, pdata, label, pos)
return newset
except:
except Exception:
self.Delete(newset)
raise
raise Exception
return

def AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None):
Expand Down Expand Up @@ -553,9 +553,9 @@ def AddCalc(self, node, label, insertafter=None, makedata=True, cdata=None):
elif cdata is not None:
self.control.paste(cdata, pdata, label, pos)
return newcalc
except:
except Exception:
self.Delete(newcalc)
raise
raise Exception
return

def CopyBranch(self, startnode):
Expand Down Expand Up @@ -611,7 +611,7 @@ def GetClipboard(self):
if cdatabytes[:16] == "pdfgui_cliboard=".encode():
cdatabytes = cdatabytes[16:]
cdata = pickle_loads(cdatabytes)
except:
except Exception:
pass
return cdata

Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/gui/phasepanelutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def canPasteIntoCells(panel):
# Strip any trailing tabs
rowlist = [r.rstrip("\t") for r in rowlist]
celllist = [r.split("\t") for r in rowlist]
except:
except wx.PyDeadObjectError:
return False

if len(celllist) == 0:
Expand Down
4 changes: 1 addition & 3 deletions src/diffpy/pdfgui/gui/plotpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

# generated by wxGlade 0.9.3 on Fri Jul 19 16:05:24 2019

import sys

import wx

from diffpy.pdfgui.control.controlerrors import ControlConfigError
Expand Down Expand Up @@ -167,7 +165,7 @@ def _represent(mixedNames):
xvals = _represent(xdata)
try:
xvals.remove("rw")
except:
except ValueError:
pass
numericStringSort(xvals)

Expand Down
18 changes: 12 additions & 6 deletions src/diffpy/pdfgui/gui/wxextensions/wx12.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def Append(self, *args, **kwargs):


if WX4:
Menu = wx.Menu
RealMenu = wx.Menu
else:
RealMenu = Menu

# ----------------------------------------------------------------------------

Expand All @@ -58,7 +60,9 @@ class ListCtrl(wx.ListCtrl):


if WX4:
ListCtrl = wx.ListCtrl
RealListCtrl = wx.ListCtrl
else:
RealListCtrl = ListCtrl

# ----------------------------------------------------------------------------

Expand All @@ -70,7 +74,9 @@ class TreeCtrl(wx.TreeCtrl):


if WX4:
TreeCtrl = wx.TreeCtrl
RealTreeCtrl = wx.TreeCtrl
else:
RealTreeCtrl = TreeCtrl

# wx.ToolBar -----------------------------------------------------------------

Expand All @@ -92,6 +98,6 @@ def patchToolBarMethods(toolbar):

# Final checks ---------------------------------------------------------------

assert WX3 ^ (Menu is wx.Menu)
assert WX3 ^ (TreeCtrl is wx.TreeCtrl)
assert WX3 ^ (ListCtrl is wx.ListCtrl)
assert WX3 ^ (RealMenu is wx.Menu)
assert WX3 ^ (RealTreeCtrl is wx.TreeCtrl)
assert WX3 ^ (RealListCtrl is wx.ListCtrl)
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/rundeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2012 Trustees of the Columbia University
# (c) 2012-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/showphasenotebookpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2016 Trustees of the Columbia University
# (c) 2016-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# diffpy.pdfgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2016 Trustees of the Columbia University
# (c) 2016-2024 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
Expand Down
Loading