Skip to content

Commit

Permalink
Merge pull request #407 from pyinat/data-dir
Browse files Browse the repository at this point in the history
Use a single data directory instead of separate 'cache' and 'user data' dirs
  • Loading branch information
JWCook authored Jul 11, 2022
2 parents 34b97a4 + 8d06357 commit 49949aa
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 213 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v

- name: Run unit tests
run: poetry run pytest -n auto

# Run tests with coverage report
- name: Run tests
run: poetry run pytest -rs -x -vv ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
Expand Down
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## 0.17.4 (2022-07-11)
* Use a single data directory instead of separate 'cache' and 'user data' dirs
* Platform-dependent; on Linux, for example, this will be `~/.local/share/pyinaturalist`

## 0.17.3 (2022-06-28)
* Add retries for requests that return invalid (truncated) JSON
* `max_retries` and `backoff_factor` arguments for `ClientSession` will apply to these retries (in
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""
# flake8: noqa: E402
import sys
from importlib.metadata import version as pkg_version
from os import makedirs, symlink
from os.path import dirname, exists, join
from shutil import copytree, rmtree
Expand All @@ -28,7 +29,6 @@

# Add project path so we can import our package
sys.path.insert(0, '..')
from pyinaturalist import __version__
from pyinaturalist.constants import DOCS_DIR, EXAMPLES_DIR, PROJECT_DIR, SAMPLE_DATA_DIR
from pyinaturalist.docs.model_docs import document_models

Expand All @@ -50,7 +50,7 @@
project = 'pyinaturalist'
source_suffix = ['.rst', '.md']
templates_path = ['_templates']
version = release = __version__
version = release = pkg_version('pyinaturalist')

# Sphinx extensions
extensions = [
Expand Down
238 changes: 40 additions & 198 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyinaturalist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa: F401, F403
# isort: skip_file
__version__ = '0.17.2'
__version__ = '0.17.4'

from pyinaturalist.auth import get_access_token
from pyinaturalist.client import iNatClient
Expand Down
23 changes: 19 additions & 4 deletions pyinaturalist/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import IO, TYPE_CHECKING, Any, BinaryIO, Dict, Iterable, List, Optional, Tuple, Union

from dateutil.relativedelta import relativedelta
from platformdirs import user_cache_dir
from platformdirs import user_data_dir

# iNaturalist URLs
API_V0 = 'https://www.inaturalist.org'
Expand Down Expand Up @@ -42,7 +42,7 @@

# Project directories
PROJECT_DIR = abspath(dirname(dirname(__file__)))
CACHE_DIR = user_cache_dir('pyinaturalist')
DATA_DIR = Path(user_data_dir()) / 'pyinaturalist'
DOCS_DIR = join(PROJECT_DIR, 'docs')
DOWNLOAD_DIR = join(PROJECT_DIR, 'downloads')
EXAMPLES_DIR = join(PROJECT_DIR, 'examples')
Expand All @@ -59,8 +59,8 @@
f'{ICONIC_TAXA_BASE_URL}/*': -1,
'*': timedelta(minutes=30),
}
CACHE_FILE = join(CACHE_DIR, 'api_requests.db')
RATELIMIT_FILE = join(CACHE_DIR, 'api_ratelimit.db')
CACHE_FILE = join(DATA_DIR, 'api_requests.db')
RATELIMIT_FILE = join(DATA_DIR, 'api_ratelimit.db')
TOKEN_EXPIRATION = timedelta(hours=1)
JWT_EXPIRATION = timedelta(days=1)

Expand Down Expand Up @@ -103,6 +103,7 @@
48222: '🟢',
47686: '🦠',
}
ROOT_TAXON_ID = 48460

# Taxonomic ranks that can be filtered on
RANKS = [
Expand Down Expand Up @@ -134,6 +135,20 @@
'kingdom',
]

# Simplified subset of ranks that are useful for display
COMMON_RANKS = [
'form',
'variety',
'species',
'genus',
'tribe',
'family',
'order',
'class',
'phylum',
'kingdom',
]

# Options for multiple choice parameters (non-endpoint-specific)
CC_LICENSES = ['CC-BY', 'CC-BY-NC', 'CC-BY-ND', 'CC-BY-SA', 'CC-BY-NC-ND', 'CC-BY-NC-SA', 'CC0']
ALL_LICENSES = CC_LICENSES + ['ALL RIGHTS RESERVED']
Expand Down
4 changes: 0 additions & 4 deletions pyinaturalist/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ class ClientSession(CacheMixin, LimiterMixin, Session):
* Rate-limiting (skipped for cached requests)
* Retries
* Timeouts
This is the default and recommended session class to use for API requests, but can be safely
replaced with any :py:class:`~requests.session.Session`-compatible class via the ``session``
argument for API request functions.
"""

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyinaturalist"
version = "0.17.3"
version = "0.17.4"
description = "iNaturalist API client for python"
authors = ["Nicolas Noé <[email protected]>", "Jordan Cook <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 49949aa

Please sign in to comment.