From 344ad8ecc334f71c66acf8f78fa8e7a6bb74e6a6 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Mon, 7 Aug 2023 14:08:34 +0100 Subject: [PATCH] An assortment of small fixes (#286) * Only CI on main and PRs * Update system_info function Fixes DKISTDC/dkist#252 * Add a little more to the readme * Reformat license so that GH detects it * Add a contributing guide * Update dkist/utils/sysinfo.py Co-authored-by: Drew Leonard --------- Co-authored-by: Drew Leonard --- .github/workflows/main.yml | 4 +++ CONTRIBUTING.md | 58 +++++++++++++++++++++++++++++++ LICENSE.rst | 45 +++++++++++++----------- README.rst | 33 +++++++++++++++--- dkist/utils/sysinfo.py | 41 +++++++++++----------- dkist/utils/tests/test_sysinfo.py | 11 ++++++ 6 files changed, 145 insertions(+), 47 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 dkist/utils/tests/test_sysinfo.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cdbde29..160caa9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,10 @@ on: # Allow manual runs through the web UI workflow_dispatch: push: + # Only run CI on release branches and main + branches: + - 'main' + - '*.*' pull_request: schedule: # ┌───────── minute (0 - 59) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d5560dda --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,58 @@ +# Contribute + +We love contributions! `dkist` is open source, built on open source, and we'd love to have you hang out in our community. + +**Imposter syndrome disclaimer**: We want your help. No, really. + +There may be a little voice inside your head that is telling you that you're not ready to be an open source contributor; that your skills aren't nearly good enough to contribute. +What could you possibly offer a project like this one? + +We assure you - the little voice in your head is wrong. +If you can write code at all, you can contribute code to open source. +Contributing to open source projects is a fantastic way to advance one's coding skills. +Writing perfect code isn't the measure of a good developer (that would disqualify all of us!); it's trying to create something, making mistakes, and learning from those mistakes. +That's how we all improve, and we are happy to help others learn. + +Being an open source contributor doesn't just mean writing code, either. +You can help out by writing documentation, tests, or even giving feedback about the project (and yes - that includes giving feedback about the contribution process). +Some of these contributions may be the most valuable to the project as a whole, because you're coming to the project with fresh eyes, so you can see the errors and assumptions that seasoned contributors have glossed over. + +Note: This disclaimer was originally written by [Adrienne Lowe](https://github.com/adriennefriend) for a [PyCon talk](https://www.youtube.com/watch?v=6Uj746j9Heo), and was adapted by dkist based on its use in the README file for the [MetPy project](https://github.com/Unidata/MetPy). + + +## Provide Feedback + +We could always use more voices and opinions in the discussions about dkist and its development from both users and developers. +You may want to suggest a new feature or tell us about how something is not working in the manner you would expect it to. +There are a number of ways to make your voice heard and we would love to hear from you. + +We strongly recommend that your first port of call would be to our lovely [matrix channel]. +Here you can get in easily get in touch with developers or users for questions or support. + +## Report Bugs + +If you run into unexpected behavior or run into a bug we urge you to please report it. +All bugs are kept track of on our [issue tracker]. +You can add a bug report there or you can report it on [matrix channel]. +Ideally, we would like a short code example so we can reproduce the bug on our own machines. + +## Provide Code + +If you are interested in contributing fixes, code or documentation to dkist please have a read of the SunPy's [newcomers guide] as it's an excellent introduction to contributing. + +dkist uses a distributed version control system called [git] and the code is hosted on [GitHub]. +To get started, create an account [on github] and fork dkist then submit your changes via a pull request. +If you are unfamiliar with this style of development, Astropy provide a sample [workflow] but you can also find lots of [tutorials] online. +You can browse our [issue list] to find something that you can tackle. +Please leave a comment on the issue on [GitHub] and stop by the [matrix channel] to let people know what you are planning to work on. + +[matrix channel]: https://app.element.io/#/room/#dki-solar-telescope:openastronomy.org +[issue tracker]: https://github.com/DKISTDC/dkist/issues +[issue list]: https://github.com/dkist/dkist/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22 +[newcomers guide]: https://docs.dkist.org/en/latest/dev_guide/contents/newcomers.html +[developer guide]: https://docs.dkist.org/en/latest/dev_guide/ +[git]: https://git-scm.com +[github]: https://github.com/DKISTDC/dkist/ +[on github]: https://help.github.com/en/articles/signing-up-for-a-new-github-account +[workflow]: https://docs.astropy.org/en/stable/development/workflow/development_workflow.html#development-workflow +[tutorials]: https://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1#awesm diff --git a/LICENSE.rst b/LICENSE.rst index 80c66e1b..6af2a99f 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -1,25 +1,28 @@ +BSD 3-Clause License + Copyright (c) 2019-2022, NSO / AURA -All rights reserved. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. -* Neither the names of DKIST, NSO or AURA nor the names of - the contributors may be used to endorse or promote products derived from this - software without specific prior written permission. +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.rst b/README.rst index 6015bec8..c8ba0d17 100644 --- a/README.rst +++ b/README.rst @@ -1,16 +1,20 @@ DKIST User Tools ----------------- +================ .. image:: https://img.shields.io/pypi/v/dkist.svg :target: https://pypi.python.org/pypi/dkist/ + :alt: PyPI for dkist package .. image:: https://img.shields.io/pypi/pyversions/dkist :alt: PyPI - Python Version .. image:: https://img.shields.io/matrix/dki-solar-telescope:openastronomy.org.svg?colorB=%23FE7900&label=Chat&logo=matrix&server_fqdn=matrix.org :target: https://app.element.io/#/room/#dki-solar-telescope:openastronomy.org + :alt: DKIST chat room on matrix .. image:: https://github.com/DKISTDC/dkist/actions/workflows/main.yml/badge.svg?branch=main :target: https://github.com/DKISTDC/dkist/actions/workflows/main.yml + :alt: Latest CI Status for dkist package .. image:: https://codecov.io/github/dkistdc/dkist/branch/master/graph/badge.svg?token=A4ggaCurqz :target: https://codecov.io/github/dkistdc/dkist + :alt: Latest codecov Status for dkist package .. image:: https://readthedocs.com/projects/dkistdc-dkist/badge/?version=latest :target: https://docs.dkist.nso.edu/projects/python-tools :alt: Documentation Status @@ -21,11 +25,30 @@ DKIST User Tools A Python library of tools for obtaining, processing and interacting with DKIST data. +Documentation +------------- + +See the documentation at `https://docs.dkist.nso.edu/projects/python-tools`__. + +Installation +------------ + +The recommended way to install ``dkist`` is with `miniforge `__. +To install ``dkist`` once miniforge is installed run the following command: + +.. code:: bash + + $ conda install dkist + +For detailed installation instructions, see the `installation guide `__ in the ``dkist`` docs. + License ------- This project is Copyright (c) NSO / AURA and licensed under -the terms of the BSD 3-Clause license. This package is based upon -the `Astropy package template `_ -which is licensed under the BSD 3-clause licence. See the licenses folder for -more information. +the terms of the BSD 3-Clause license. + +Code of Conduct +--------------- + +When you are interacting with the `dkist` project you are asked to follow the SunPy `Code of Conduct`__. diff --git a/dkist/utils/sysinfo.py b/dkist/utils/sysinfo.py index 039b76ad..9c7bcde8 100644 --- a/dkist/utils/sysinfo.py +++ b/dkist/utils/sysinfo.py @@ -1,46 +1,45 @@ import platform +from importlib.metadata import version, distribution -from pkg_resources import get_distribution - -from sunpy.extern.distro import linux_distribution -from sunpy.util.sysinfo import find_dependencies +import sunpy.extern.distro as distro +from sunpy.util.sysinfo import find_dependencies, get_keys_list, get_requirements __all__ = ['system_info'] def system_info(): """ - Display information about your system for submitting bug reports. + Prints one's system info in an "attractive" fashion. """ - base_reqs = get_distribution("dkist").requires() - base_reqs = {base_req.name.lower() for base_req in base_reqs} - - missing_packages, installed_packages = find_dependencies(package="dkist") + package_name = "dkist" + requirements = get_requirements(package_name) + base_reqs = get_keys_list(requirements['required']) + missing_packages, installed_packages = find_dependencies(package=package_name) extra_prop = {"System": platform.system(), "Arch": f"{platform.architecture()[0]}, ({platform.processor()})", "Python": platform.python_version(), - "SunPy": get_distribution("dkist").version} + package_name: version(package_name)} sys_prop = {**installed_packages, **missing_packages, **extra_prop} - - print("==============================") - print("DKIST Installation Information") - print("==============================") + title_str = f"{package_name} Installation Information" + print("=" * len(title_str)) + print(title_str) + print("=" * len(title_str)) print() print("General") print("#######") if sys_prop['System'] == "Linux": - distro = " ".join(linux_distribution()) - print(f"OS: {distro} (Linux {platform.release()})") + print(f"OS: {distro.name()} ({distro.version()}, Linux {platform.release()})") elif sys_prop['System'] == "Darwin": print(f"OS: Mac OS {platform.mac_ver()[0]}") elif sys_prop['System'] == "Windows": print(f"OS: Windows {platform.release()} {platform.version()}") else: print("Unknown OS") - for sys_info in ['Arch', 'SunPy']: - print('{} : {}'.format(sys_info, sys_prop[sys_info])) + for sys_info in ['Arch', package_name]: + print(f'{sys_info}: {sys_prop[sys_info]}') + print(f'Installation path: {distribution(package_name)._path}') print() - print("Required Dependices") - print("###################") + print("Required Dependencies") + print("#####################") for req in base_reqs: - print('{}: {}'.format(req, sys_prop[req])) + print(f'{req}: {sys_prop[req]}') diff --git a/dkist/utils/tests/test_sysinfo.py b/dkist/utils/tests/test_sysinfo.py new file mode 100644 index 00000000..4d045a14 --- /dev/null +++ b/dkist/utils/tests/test_sysinfo.py @@ -0,0 +1,11 @@ +import dkist + + +def test_system_info(capsys): + """ + A very minimal test for system_info to test it runs. + """ + dkist.system_info() + captured_output = capsys.readouterr().out + assert "dkist Installation Information" in captured_output + assert f"dkist: {dkist.__version__}" in captured_output