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

ENH: initial CLI commit #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======
Credits
=======

Maintainer
----------

* SLAC National Accelerator Laboratory <>

Contributors
------------

Interested? See: `CONTRIBUTING.rst <CONTRIBUTING.rst>`_
103 changes: 103 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
============
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
----------------------

Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/pcdshub/[email protected]:pcdshub/pygrafana.git/issues.

If you are reporting a bug, please include:

* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug"
is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

pygrafana could always use more documentation, whether
as part of the official pygrafana docs, in docstrings,
or even on the web in blog posts, articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/pcdshub/[email protected]:pcdshub/pygrafana.git/issues.

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
------------

Ready to contribute? Here's how to set up `[email protected]:pcdshub/pygrafana.git` for local development.

1. Fork the `[email protected]:pcdshub/pygrafana.git` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/[email protected]:pcdshub/pygrafana.git.git

3. Install your local copy into a new conda environment. Assuming you have conda installed, this is how you set up your fork for local development::

$ conda create -n [email protected]:pcdshub/pygrafana.git python=3.9 pip
$ cd [email protected]:pcdshub/pygrafana.git/
$ pip install -e .

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. Install and enable ``pre-commit`` for this repository::

$ pip install pre-commit
$ pre-commit install

6. Add new tests for any additional functionality or bugs you may have discovered. And, of course, be sure that all previous tests still pass by running::

$ pytest -v

7. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

8. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your
new functionality into a function with a docstring, and add the feature to
the list in README.rst.
3. The pull request should work for Python 3.9 and up. Check the GitHub Actions status
and make sure that the tests pass for all supported Python versions.
39 changes: 39 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Copyright (c) 2023, The Board of Trustees of the Leland Stanford Junior
University, through SLAC National Accelerator Laboratory (subject to receipt
of any required approvals from the U.S. Dept. of Energy). All rights reserved.
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.

(3) Neither the name of the Leland Stanford Junior University, SLAC National
Accelerator Laboratory, U.S. Dept. of Energy 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 OWNER, THE UNITED STATES GOVERNMENT,
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.

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to SLAC National Accelerator Laboratory,
without imposing a separate written license agreement for such Enhancements,
then you hereby grant the following license: a non-exclusive, royalty-free
perpetual license to install, use, modify, prepare derivative works, incorporate
into other computer software, distribute, and sublicense such Enhancements or
derivative works thereof, in binary and source code form.
19 changes: 19 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include AUTHORS.rst
include CONTRIBUTING.rst
include LICENSE
include README.rst
include dev-requirements.txt
include docs-requirements.txt
include requirements.txt

recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat

# If including data files in the package, add a single file/glob:
#
# include path/to/data_file
#
# Or multiple recursively:
# recursive-include path file*glob1* file*glob*2
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
===============================
pygrafana
===============================

.. image:: https://github.com/pcdshub/[email protected]:pcdshub/pygrafana.git/actions/workflows/standard.yml/badge.svg
:target: https://github.com/pcdshub/[email protected]:pcdshub/pygrafana.git/actions/workflows/standard.yml

.. image:: https://img.shields.io/pypi/v/[email protected]:pcdshub/pygrafana.git.svg
:target: https://pypi.python.org/pypi/[email protected]:pcdshub/pygrafana.git


`Documentation <https://pcdshub.github.io/[email protected]:pcdshub/pygrafana.git/>`_

python CLI for interacting with grafana webserver.

Requirements
------------

* Python 3.9+

Installation
------------

::

$ pip install .

Running the Tests
-----------------
::

$ pytest -v
36 changes: 36 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% set package_name = "[email protected]:pcdshub/pygrafana.git" %}
{% set import_name = "pygrafana" %}
{% set version = load_file_regex(load_file=os.path.join(import_name, "_version.py"), regex_pattern=".*version = '(\S+)'").group(1) %}

package:
name: {{ package_name }}
version: {{ version }}

source:
path: ..

build:
number: 0
noarch: python
script: {{ PYTHON }} -m pip install . -vv

requirements:
build:
- python >=3.9
- pip
- setuptools
- setuptools_scm
run:
- python >=3.9

test:
imports:
- {{ import_name }}
requires:
- pytest

about:
home: https://github.com/pcdshub/[email protected]:pcdshub/pygrafana.git
license: LicenseRef-BSD-3-Clause-SLAC
license_family: BSD
summary: python CLI for interacting with grafana webserver.
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are required for developing the package (running the tests) but not
# necessarily required for _using_ it.
pytest
pytest-cov
10 changes: 10 additions & 0 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# These are required for developing the package (building the documentation)
# but not necessarily required for _using_ it.
docs-versions-menu
numpydoc
recommonmark
sphinx
sphinx-copybutton
sphinx_rtd_theme
# Required for compatibility with Sphinx 6.0+:
sphinxcontrib-jquery
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = cookiecutterproject_name
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=cookiecutterproject_name

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
42 changes: 42 additions & 0 deletions docs/pre-release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

ISSUE=$1
shift
DESCRIPTION=$*

if [[ -z "$ISSUE" || -z "$DESCRIPTION" ]]; then
echo "Usage: $0 (ISSUE NUMBER) (DESCRIPTION)"
exit 1
fi

re_issue_number='^[1-9][0-9]*$'

if ! [[ "$ISSUE" =~ $re_issue_number ]]; then
echo "Error: Issue number is not a number: $ISSUE"
echo
echo "This should preferably be the issue number that this pull request solves."
echo "We may also accept the Pull Request number in place of the issue."
exit 1
fi

echo "Issue: $ISSUE"
echo "Description: $DESCRIPTION"

FILENAME=source/upcoming_release_notes/${ISSUE}-${DESCRIPTION// /_}.rst

pushd "$(dirname "$0")" || exit 1

sed -e "s/IssueNumber Title/${ISSUE} ${DESCRIPTION}/" \
"source/upcoming_release_notes/template-short.rst" > "${FILENAME}"

if [ -z "${EDITOR}" ]; then
echo "EDITOR environment variable is not set, defaulting to 'vi'."
EDITOR="vi"
fi

if ${EDITOR} "${FILENAME}"; then
echo "Adding ${FILENAME} to the git repository..."
git add "${FILENAME}"
fi

popd || exit 0
Loading