From 0c9a4a7285648a0c83373a6860ee686a1c7db720 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 28 Nov 2020 10:13:39 +0000 Subject: [PATCH 1/2] package update and test fixes --- .gitignore | 2 +- .pre-commit-config.yaml | 6 ++-- MANIFEST.in | 4 +++ pyproject.toml | 4 --- setup.cfg | 5 ++- setup.py | 23 +++---------- sunkit_instruments/__init__.py | 8 ++--- sunkit_instruments/_dev/__init__.py | 6 ++++ sunkit_instruments/_dev/scm_version.py | 12 +++++++ sunkit_instruments/lyra/tests/test_lyra.py | 2 +- sunkit_instruments/version.py | 40 ++++++++++++++++++++++ tox.ini | 4 +-- 12 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 sunkit_instruments/_dev/__init__.py create mode 100644 sunkit_instruments/_dev/scm_version.py create mode 100644 sunkit_instruments/version.py diff --git a/.gitignore b/.gitignore index 1002e135..e1e9d187 100644 --- a/.gitignore +++ b/.gitignore @@ -217,7 +217,7 @@ examples/**/*.csv # This is incase you run the figure tests figure_test_images* tags -sunkit_instruments/version.py +sunkit_instruments/_version.py ### Pycharm(?) .idea diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f911e335..a7ca422d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,7 +60,7 @@ repos: # W605 - Fix invalid escape sequence 'x'. # W690 - Fix various deprecated code (via lib2to3). - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 + rev: 3.8.4 hooks: - id: flake8 args: ['--count', '--select', 'E101,E11,E111,E112,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E133,E20,E211,E231,E241,E242,E251,E252,E26,E265,E266,E27,E301,E302,E303,E304,E305,E306,E401,E402,E502,E701,E711,E712,E713,E714,E722,E731,E901,E902,F822,F823,W191,W291,W292,W293,W391,W601,W602,W603,W604,W605,W690'] @@ -72,13 +72,13 @@ repos: args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable'] exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|docs/conf.py)$" - repo: https://github.com/timothycrosley/isort - rev: 5.5.2 + rev: 5.6.4 hooks: - id: isort args: ['--sp','setup.cfg'] exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|docs/conf.py)$" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v3.3.0 hooks: - id: check-ast - id: check-case-conflict diff --git a/MANIFEST.in b/MANIFEST.in index 4dd75434..5709e033 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -15,3 +15,7 @@ prune docs/_build prune docs/api global-exclude *.pyc *.o + +# This subpackage is only used in development checkouts and should not be +# included in built tarballs +prune sunkit_instruments/_dev diff --git a/pyproject.toml b/pyproject.toml index 54319569..3d1b91d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,6 @@ build-backend = 'setuptools.build_meta' number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file." - [ tool.gilesbot.milestones ] - enabled = true - missing_message_long = "This pull request does not have a milestone assigned to it. Only maintainers can change this, so you don't need to worry about it. :smile:" - [tool.towncrier] package = "sunkit_instruments" filename = "CHANGELOG.rst" diff --git a/setup.cfg b/setup.cfg index fe790762..088c38be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,10 +50,13 @@ docs = towncrier sunpy-sphinx-theme +[options.packages.find] +exclude = sunkit_instruments._dev + [tool:pytest] minversion = 3.0 testpaths = "sunkit_instruments" "docs" -norecursedirs = ".tox" "build" "docs[\/]_build" "docs[\/]generated" "*.egg-info" "examples" ".jupyter" ".history" "tools" +norecursedirs = ".tox" "build" "docs[\/]_build" "docs[\/]generated" "*.egg-info" "examples" ".history" "sunkit_instruments/_dev" doctest_plus = enabled doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS addopts = -rsa -vvv --doctest-rst --doctest-ignore-import-errors diff --git a/setup.py b/setup.py index cb0115b1..09e3782a 100755 --- a/setup.py +++ b/setup.py @@ -5,21 +5,6 @@ from setuptools.config import read_configuration -################################################################################ -# Actual setup.py content -################################################################################ - -VERSION_TEMPLATE = """ -# Note that we need to fall back to the hard-coded version if either -# setuptools_scm can't be imported or setuptools_scm can't determine the -# version, so we catch the generic 'Exception'. -try: - from setuptools_scm import get_version - __version__ = get_version(root='..', relative_to=__file__) -except Exception: - __version__ = '{version}' -""".lstrip() - ################################################################################ # Programmatically generate some extras combos. ################################################################################ @@ -34,7 +19,7 @@ # Concatenate all the values together for 'all' extras['all'] = list(chain.from_iterable(ex_extras.values())) -setup(extras_require=extras, - use_scm_version={'write_to': os.path.join('sunkit_instruments', 'version.py'), - 'write_to_template': VERSION_TEMPLATE}, - ) +setup( + extras_require=extras, + use_scm_version={'write_to': os.path.join('sunkit_instruments', '_version.py')} +) diff --git a/sunkit_instruments/__init__.py b/sunkit_instruments/__init__.py index 1906901d..7e2bed1c 100644 --- a/sunkit_instruments/__init__.py +++ b/sunkit_instruments/__init__.py @@ -9,15 +9,11 @@ """ import sys +from .version import version as __version__ # NOQA + # Enforce Python version check during package import. __minimum_python_version__ = "3.7" -try: - from .version import __version__ -except ImportError: - print("version.py not found, please reinstall sunkit_instruments.") - __version__ = "unknown" - class UnsupportedPythonError(Exception): """ diff --git a/sunkit_instruments/_dev/__init__.py b/sunkit_instruments/_dev/__init__.py new file mode 100644 index 00000000..72583c08 --- /dev/null +++ b/sunkit_instruments/_dev/__init__.py @@ -0,0 +1,6 @@ +""" +This package contains utilities that are only used when developing drms in a +copy of the source repository. +These files are not installed, and should not be assumed to exist at +runtime. +""" diff --git a/sunkit_instruments/_dev/scm_version.py b/sunkit_instruments/_dev/scm_version.py new file mode 100644 index 00000000..b33a5bac --- /dev/null +++ b/sunkit_instruments/_dev/scm_version.py @@ -0,0 +1,12 @@ +# Try to use setuptools_scm to get the current version; this is only used +# in development installations from the git repository. +import os.path + +try: + from setuptools_scm import get_version + + version = get_version(root=os.path.join('..', '..'), relative_to=__file__) +except ImportError: + raise ImportError('setuptools_scm not installed') +except Exception as e: + raise ValueError(f'setuptools_scm broken with {e}') diff --git a/sunkit_instruments/lyra/tests/test_lyra.py b/sunkit_instruments/lyra/tests/test_lyra.py index 886bc79c..9b6f9322 100644 --- a/sunkit_instruments/lyra/tests/test_lyra.py +++ b/sunkit_instruments/lyra/tests/test_lyra.py @@ -63,7 +63,7 @@ def test_split_series_using_lytaf(): assert len(split) == 4 assert is_time_equal(split[0]['subtimes'][0], parse_time((2010, 6, 13, 2, 0))) assert is_time_equal(split[0]['subtimes'][-1], parse_time((2010, 6, 13, 2, 7, 2))) - assert is_time_equal(split[3]['subtimes'][0], parse_time((2010, 6, 13, 2, 59, 42))) + assert is_time_equal(split[3]['subtimes'][0], parse_time((2010, 6, 13, 2, 59, 41))) assert is_time_equal(split[3]['subtimes'][-1], parse_time((2010, 6, 13, 2, 59, 58))) # Test case when no LYTAF events found in time series. diff --git a/sunkit_instruments/version.py b/sunkit_instruments/version.py new file mode 100644 index 00000000..4c6e402a --- /dev/null +++ b/sunkit_instruments/version.py @@ -0,0 +1,40 @@ +# NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed +# This file is not included in sunpy wheels/tarballs, so otherwise it will +# fall back on the generated _version module. +try: + try: + from ._dev.scm_version import version + except ImportError: + from ._version import version +except Exception: + import warnings + + warnings.warn( + f'could not determine {__name__.split(".")[0]} package version; this indicates a broken installation' + ) + del warnings + + version = '0.0.0' + + +# We use LooseVersion to define major, minor, micro, but ignore any suffixes. +def split_version(version): + pieces = [0, 0, 0] + + try: + from distutils.version import LooseVersion + + for j, piece in enumerate(LooseVersion(version).version[:3]): + pieces[j] = int(piece) + + except Exception: + pass + + return pieces + + +major, minor, bugfix = split_version(version) + +del split_version # clean up namespace. + +release = 'dev' not in version diff --git a/tox.ini b/tox.ini index b6c947f2..8ffb80d5 100644 --- a/tox.ini +++ b/tox.ini @@ -58,7 +58,7 @@ extras = dev commands = !online: {env:PYTEST_COMMAND} {posargs} - online: {env:PYTEST_COMMAND} --reruns 2 --timeout=60 --remote-data=any -m "remote_data" {posargs} + online: {env:PYTEST_COMMAND} --reruns 2 --timeout=180 --remote-data=any {posargs} [testenv:build_docs] usedevelop = true @@ -77,4 +77,4 @@ deps = pre-commit commands = pre-commit install-hooks - pre-commit run --verbose --all-files --show-diff-on-failure + pre-commit run --color auto --all-files --show-diff-on-failure From e9d3cd85573fda8ad6b2ac979239ab80586690f5 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 28 Nov 2020 10:53:38 +0000 Subject: [PATCH 2/2] updated CI --- azure-pipelines.yml | 145 ++++++++++++++++++++++++------------- docs/code_ref/goes_xrs.rst | 2 +- setup.cfg | 43 +++++------ tox.ini | 2 + 4 files changed, 118 insertions(+), 74 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e79d0421..371fa638 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,53 +30,98 @@ trigger: - '*pre*' - '*post*' -jobs: -- template: run-tox-env.yml@OpenAstronomy - parameters: - submodules: false - coverage: codecov - toxdeps: tox-pypi-filter - posargs: -n=4 - libraries: - apt: - - graphviz - - envs: - - macos: py38 - name: py38_test - - - windows: py37 - name: py37_test - - - linux: py38-online - name: py38_test_online - posargs: -n=1 - - - linux: codestyle - name: python_codestyle - pytest: false - - - linux: py37-oldestdeps - name: py37_test_oldestdeps - - - linux: py38-devdeps - -# On branches which aren't master, and not Pull Requests, build the wheels but only upload them on tags -- ${{ if and(ne(variables['Build.Reason'], 'PullRequest'), not(contains(variables['Build.SourceBranch'], 'master'))) }}: - - template: publish.yml@OpenAstronomy - parameters: - # Only Upload to PyPI on tags - ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: - pypi_connection_name : 'PyPI' - test_extras: 'dev' - test_command: 'pytest -p no:warnings --doctest-rst -m "not figure" --pyargs sunkit_instruments' - submodules: false - - targets: - - wheels_universal - - sdist - dependsOn: - - py37_test - - py38_test - - py38_test_online - - py37_test_oldestdeps +pr: + autoCancel: true + +stages: + - stage: FirstPhaseTests + displayName: Core Tests + jobs: + - template: run-tox-env.yml@OpenAstronomy + parameters: + default_python: '3.8' + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + posargs: -n=4 + + envs: + - linux: codestyle + name: style_check + pytest: false + libraries: {} + + - linux: py38 + + - stage: SecondPhaseTests + displayName: Stage 2 Tests + dependsOn: FirstPhaseTests + jobs: + - template: run-tox-env.yml@OpenAstronomy + parameters: + default_python: '3.8' + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + posargs: -n=4 + + libraries: + apt: + - graphviz + + envs: + - macos: py37 + + - windows: py39 + + - linux: build_docs + posargs: " " + pytest: false + + - linux: py38-online + + - linux: py37-oldestdeps + + + - ${{ if or(eq(variables['Build.Reason'], 'Schedule'), eq(variables['Build.Reason'], 'Manual')) }}: + - stage: CronTests + displayName: Cron Tests + dependsOn: [] # Don't wait on other stages + jobs: + - template: run-tox-env.yml@OpenAstronomy + parameters: + default_python: '3.8' + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + posargs: -n=4 + + libraries: + yum: + - openssl-devel + - freetype-devel + - libpng-devel + - hdf5-devel + + envs: + - linux32: py38-32bit + manylinux_image: manylinux2010_i686 + + - linux: py38-devdeps + + # On branches which aren't master, and not Pull Requests, build the wheels but only upload them on tags + - ${{ if and(ne(variables['Build.Reason'], 'PullRequest'), or(ne(variables['Build.SourceBranchName'], 'master'), eq(variables['Build.Reason'], 'Schedule'), eq(variables['Build.Reason'], 'Manual'))) }}: + - stage: Release + dependsOn: SecondPhaseTests + jobs: + - template: publish.yml@OpenAstronomy + parameters: + # Only Upload to PyPI on tags + ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: + pypi_connection_name : 'PyPI' + test_extras: 'dev' + test_command: 'pytest -p no:warnings --doctest-rst --pyargs sunkit_instruments' + submodules: false + targets: + - wheels_universal + - sdist diff --git a/docs/code_ref/goes_xrs.rst b/docs/code_ref/goes_xrs.rst index f9e0a728..1cc7a0c3 100644 --- a/docs/code_ref/goes_xrs.rst +++ b/docs/code_ref/goes_xrs.rst @@ -1 +1 @@ -.. automodapi:: sunkit_instruments.fermi +.. automodapi:: sunkit_instruments.goes_xrs diff --git a/setup.cfg b/setup.cfg index 088c38be..2e9857e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,7 +12,7 @@ url = https://sunpy.org edit_on_github = True github_project = sunpy/sunkit_instruments platform = any -keywords = solar physics, solar, science, sun, wcs, coordinates +keywords = solar physics, solar, science, telescope, instrumentation classifiers = Intended Audience :: Science/Research License :: OSI Approved :: BSD License @@ -32,11 +32,11 @@ include_package_data = True setup_requires = setuptools_scm install_requires = + astropy + matplotlib numpy pandas - sunpy[net] >= 2.0.0 - matplotlib - astropy + sunpy[net,timeseries] >= 2.0.0 [options.extras_require] tests = @@ -47,14 +47,13 @@ tests = docs = sphinx sphinx-automodapi - towncrier sunpy-sphinx-theme + towncrier [options.packages.find] exclude = sunkit_instruments._dev [tool:pytest] -minversion = 3.0 testpaths = "sunkit_instruments" "docs" norecursedirs = ".tox" "build" "docs[\/]_build" "docs[\/]generated" "*.egg-info" "examples" ".history" "sunkit_instruments/_dev" doctest_plus = enabled @@ -63,9 +62,7 @@ addopts = -rsa -vvv --doctest-rst --doctest-ignore-import-errors markers = remote_data: marks this test function as needing remote data. online: marks this test function as needing online connectivity. - figure: marks this test function as using hash-based Matplotlib figure verification. This mark is not meant to be directly applied, but is instead automatically applied when a test function uses the @sunpy.tests.helpers.figure_test decorator. - flaky - array_compare + array_compare: compare arrays remote_data_strict = True # Pin junit behaviour; we might want to update this to xunit2 at some point junit_family=xunit1 @@ -119,24 +116,24 @@ sections = STDLIB, THIRDPARTY, ASTROPY, FIRSTPARTY, LOCALFOLDER [coverage:run] omit = - sunkit_instruments/conftest.py - sunkit_instruments/cython_version* - sunkit_instruments/*setup* - sunkit_instruments/extern/* - sunkit_instruments/*/tests/* - sunkit_instruments/version* - sunkit_instruments/__init__* - sunkit_instruments/data/sample.py - sunkit_instruments/data/_sample.py + */sunkit_instruments/__init__* + */sunkit_instruments/*/tests/* + */sunkit_instruments/*setup* */sunkit_instruments/conftest.py */sunkit_instruments/cython_version* - */sunkit_instruments/*setup* + */sunkit_instruments/data/_sample.py + */sunkit_instruments/data/sample.py */sunkit_instruments/extern/* - */sunkit_instruments/*/tests/* */sunkit_instruments/version* - */sunkit_instruments/__init__* - */sunkit_instruments/data/sample.py - */sunkit_instruments/data/_sample.py + sunkit_instruments/__init__* + sunkit_instruments/*/tests/* + sunkit_instruments/*setup* + sunkit_instruments/conftest.py + sunkit_instruments/cython_version* + sunkit_instruments/data/_sample.py + sunkit_instruments/data/sample.py + sunkit_instruments/extern/* + sunkit_instruments/version* [coverage:report] exclude_lines = diff --git a/tox.ini b/tox.ini index 8ffb80d5..640c33dd 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,8 @@ deps = # The devdeps factor is intended to be used to install the latest developer version. # of key dependencies. devdeps: git+https://github.com/sunpy/sunpy + devdeps: scipy + devdeps: h5netcdf # These are specific online extras we use to run the online tests. online: pytest-rerunfailures online: pytest-timeout