Skip to content

Commit 495dc64

Browse files
committed
added nb examples
1 parent b0cdeb5 commit 495dc64

24 files changed

+693
-195
lines changed

.gitignore

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
*.egg-info
2-
doc/html
3-
doc/doctrees
42
dist
53
tmp
64

@@ -37,3 +35,9 @@ setup_env_conda.sh
3735
setup_env_virtualenv.sh
3836
.idea
3937
.pytest_cache
38+
39+
# sphinx
40+
docs/_build/
41+
42+
# IPython
43+
.ipynb_checkpoints

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ os:
88
- linux
99
sudo: false
1010
install:
11-
- pip install -e .[testing]
11+
- pip install -e .[dev]
1212

1313
script:
1414
- pytest

Makefile

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.PHONY: clean clean-test clean-pyc clean-build docs help
2+
.DEFAULT_GOAL := help
3+
4+
define BROWSER_PYSCRIPT
5+
import os, webbrowser, sys
6+
from urllib.request import pathname2url
7+
8+
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
9+
endef
10+
export BROWSER_PYSCRIPT
11+
12+
define PRINT_HELP_PYSCRIPT
13+
import re, sys
14+
15+
for line in sys.stdin:
16+
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
17+
if match:
18+
target, help = match.groups()
19+
print("%-20s %s" % (target, help))
20+
endef
21+
export PRINT_HELP_PYSCRIPT
22+
23+
BROWSER := python -c "$$BROWSER_PYSCRIPT"
24+
25+
help:
26+
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
27+
28+
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
29+
30+
clean-build: ## remove build artifacts
31+
rm -fr build/
32+
rm -fr dist/
33+
rm -fr .eggs/
34+
find . -name '*.egg-info' -exec rm -fr {} +
35+
find . -name '*.egg' -exec rm -f {} +
36+
37+
clean-pyc: ## remove Python file artifacts
38+
find . -name '*.pyc' -exec rm -f {} +
39+
find . -name '*.pyo' -exec rm -f {} +
40+
find . -name '*~' -exec rm -f {} +
41+
find . -name '__pycache__' -exec rm -fr {} +
42+
43+
clean-test: ## remove test and coverage artifacts
44+
rm -fr .tox/
45+
rm -f .coverage
46+
rm -fr htmlcov/
47+
rm -fr .pytest_cache
48+
49+
lint: ## check style with flake8
50+
flake8 pyesgf
51+
52+
test: ## run tests quickly with the default Python
53+
pytest -v -m 'not slow and not online'
54+
55+
test-all: ## run tests on every Python version
56+
pytest -v
57+
58+
coverage: ## check code coverage quickly with the default Python
59+
coverage run --source birdy -m pytest
60+
coverage report -m
61+
coverage html
62+
$(BROWSER) htmlcov/index.html
63+
64+
docs: ## generate Sphinx HTML documentation, including API docs
65+
$(MAKE) -C docs clean
66+
$(MAKE) -C docs html
67+
$(BROWSER) docs/_build/html/index.html
68+
69+
servedocs: docs ## compile the docs watching for changes
70+
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
71+
72+
release: dist ## package and upload a release
73+
twine upload dist/*
74+
75+
dist: clean ## builds source and wheel package
76+
python setup.py sdist
77+
python setup.py bdist_wheel
78+
ls -l dist
79+
80+
install: clean ## install the package to the active Python's site-packages
81+
python setup.py install
82+
pip install -e .
83+
84+
develop: clean ## like install but with testing packages
85+
pip install -e .[dev]

README.rst

+20-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,28 @@
1010
:target: https://github.com/ESGF/esgf-pyclient/blob/master/LICENSE
1111
:alt: GitHub license
1212

13-
This package contains API code for calling the `ESGF Search API`_ within
14-
client code. The initial implementation is in Python.
13+
ESGF PyClient is a Python package designed for interacting with the `Earth System Grid Federation`_ system.
14+
Currently this package contains API code for calling the `ESGF Search API`_ within
15+
client code.
16+
17+
You can try it online using Binder, or view the notebooks on NBViewer.
18+
19+
.. image:: https://mybinder.org/badge_logo.svg
20+
:target: https://mybinder.org/v2/gh/ESGF/esgf-pyclient.git/master?filepath=notebooks
21+
:alt: Binder Launcher
22+
:height: 20
23+
24+
.. image:: https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg
25+
:target: https://nbviewer.jupyter.org/github/ESGF/esgf-pyclient/tree/master/notebooks/
26+
:alt: NBViewer
27+
:height: 20
1528

1629
Please submit bugs and feature requests through the bug tracker on
17-
github. Pull requests are always welcome.
30+
github_. Pull requests are always welcome.
1831

19-
Full `documentation`_ is available on ReadTheDocs or in the docs directory.
32+
Full documentation_ is available on ReadTheDocs or in the docs directory.
2033

34+
.. _`Earth System Grid Federation`: http://esgf.org
2135
.. _`ESGF Search API`: https://github.com/ESGF/esgf.github.io/wiki/ESGF_Search_REST_API
22-
.. _`documentation`: http://esgf-pyclient.readthedocs.org
36+
.. _documentation: http://esgf-pyclient.readthedocs.org
37+
.. _`github`: https://github.com/ESGF/esgf-pyclient

binder/environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../environment.yml

binder/postBuild

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip install -e .[testing]

docs/concepts.rst

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
2-
31
Search Concepts
42
===============
53

6-
The :mod:`pyesgf.search` interface to ESGF search reflects the typical workflow of a user navigating through the sets of facets categorising available data.
4+
The :mod:`pyesgf.search` interface to ESGF search reflects the typical workflow of a user navigating through the sets of facets categorising available data.
75

86

97
Keyword classification
@@ -15,9 +13,9 @@ The keyword arguments described in the `ESGF Search API`_ have a wide veriety of
1513
System keywords
1614
'''''''''''''''
1715

18-
=========== ================ ===================================================================================================
16+
=========== ================ ===================================================================================================
1917
API keyword class Notes
20-
=========== ================ ===================================================================================================
18+
=========== ================ ===================================================================================================
2119
limit SearchConnection Set in :meth:`SearchConnection:send_query` method or transparently through :class:`SearchContext`
2220
offset SearchConnection Set in :meth:`SearchConnection:send_query` method or transparently through :class:`SearchContext`
2321
shards SearchConnection Set in constructor
@@ -32,7 +30,7 @@ to SearchContext Set in constructor. Use "to_timestamp" in the con
3230
fields n/a Managed internally
3331
format n/a Managed internally
3432
id n/a Managed internally
35-
=========== ================ ===================================================================================================
33+
=========== ================ ===================================================================================================
3634

3735
Temporal keywords
3836
'''''''''''''''''
@@ -74,7 +72,7 @@ SearchContext objects can be created in several ways:
7472
ResultSet
7573
'''''''''
7674

77-
:class:`ResultSet` instances are returned by the :meth:`SearchContext.search` method and represent the results from a query. They supports transparent paging of results with a client-side cache.
75+
:class:`ResultSet` instances are returned by the :meth:`SearchContext.search` method and represent the results from a query. They supports transparent paging of results with a client-side cache.
7876

7977
Result
8078
''''''

docs/conf.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,29 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
15-
from ConfigParser import SafeConfigParser
16-
import os.path as op
14+
import sys
15+
import os
1716

18-
# Get distribution configuration
19-
dist_root = op.join(op.dirname(__file__), '..')
20-
setup_cfg = op.join(dist_root, 'setup.cfg')
21-
dist_config = SafeConfigParser()
22-
dist_config.read(setup_cfg)
23-
24-
sys.path.append(dist_root)
17+
sys.path.insert(0, os.path.abspath('../'))
2518
from pyesgf import __version__ as pyesgf_version
2619

2720
# If extensions (or modules to document with autodoc) are in another directory,
2821
# add these directories to sys.path here. If the directory is relative to the
2922
# documentation root, use os.path.abspath to make it absolute, like shown here.
30-
#sys.path.insert(0, os.path.abspath('.'))
23+
# sys.path.insert(0, os.path.abspath('.'))
3124

3225
# -- General configuration -----------------------------------------------------
3326

3427
# If your documentation needs a minimal Sphinx version, state it here.
35-
#needs_sphinx = '1.0'
28+
# needs_sphinx = '1.0'
3629

3730
# Add any Sphinx extension module names here, as strings. They can be extensions
3831
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
39-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode']
32+
extensions = [
33+
'nbsphinx',
34+
'sphinx.ext.autodoc',
35+
'sphinx.ext.todo',
36+
'sphinx.ext.viewcode']
4037

4138
# Add any paths that contain templates here, relative to this directory.
4239
templates_path = ['_templates']
@@ -105,7 +102,7 @@
105102

106103
# The theme to use for HTML and HTML Help pages. See the documentation for
107104
# a list of builtin themes.
108-
html_theme = 'pyramid'
105+
html_theme = 'alabaster'
109106
#html_theme_path = []
110107
#html_theme_options = {}
111108

@@ -248,3 +245,7 @@
248245

249246
# How to display URL addresses: 'footnote', 'no', or 'inline'.
250247
#texinfo_show_urls = 'footnote'
248+
249+
# -- nbsphinx options ----------------------------------------------------------
250+
# https://nbsphinx.readthedocs.io/en/0.4.2/executing-notebooks.html
251+
nbsphinx_execute = 'never'

docs/environment.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
channels:
2+
- conda-forge
3+
dependencies:
4+
- pip
5+
- python>=3
6+
- sphinx>=1.6
7+
- pandoc
8+
- nbconvert!=5.4
9+
- ipykernel
10+
- pip:
11+
- nbsphinx

0 commit comments

Comments
 (0)