{"id":44079424,"url":"https://github.com/pacificclimate/climate-explorer-backend","last_synced_at":"2026-02-08T08:34:33.507Z","repository":{"id":2861819,"uuid":"47586750","full_name":"pacificclimate/climate-explorer-backend","owner":"pacificclimate","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-18T20:21:03.000Z","size":20495,"stargazers_count":4,"open_issues_count":37,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-18T20:41:33.061Z","etag":null,"topics":["actions","docker","make","pip"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pacificclimate.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-12-07T23:53:24.000Z","updated_at":"2025-06-12T20:47:57.000Z","dependencies_parsed_at":"2023-11-24T07:27:26.818Z","dependency_job_id":"77558011-b9c5-4967-a3d7-c65c938eabf7","html_url":"https://github.com/pacificclimate/climate-explorer-backend","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/pacificclimate/climate-explorer-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacificclimate%2Fclimate-explorer-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacificclimate%2Fclimate-explorer-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacificclimate%2Fclimate-explorer-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacificclimate%2Fclimate-explorer-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pacificclimate","download_url":"https://codeload.github.com/pacificclimate/climate-explorer-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pacificclimate%2Fclimate-explorer-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29225478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T06:05:31.539Z","status":"ssl_error","status_checked_at":"2026-02-08T05:58:33.853Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","docker","make","pip"],"created_at":"2026-02-08T08:34:32.435Z","updated_at":"2026-02-08T08:34:33.502Z","avatar_url":"https://github.com/pacificclimate.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PCIC Climate Explorer Backend\n\n![Python CI](https://github.com/pacificclimate/climate-explorer-backend/workflows/Python%20CI/badge.svg)\n![Docker Publishing](https://github.com/pacificclimate/climate-explorer-backend/workflows/Docker%20Publishing/badge.svg)\n[![Code Climate](https://codeclimate.com/github/pacificclimate/climate-explorer-backend/badges/gpa.svg)](https://codeclimate.com/github/pacificclimate/climate-explorer-backend)\n\n## Setup\n\n### System Dependencies\n\nA few system dependencies are necessary to subsequently build the\nvarious python packages. In Ubuntu these are:\n\n```bash\n$ sudo apt-get install libpq-dev python-dev libhdf5-dev libnetcdf-dev libgdal-dev libffi-dev\n```\n\nUnder other systems, you may need to adjust the install command as\nwell as the specific names of the packages.\n\n### GDAL\n\nInstalling the GDAL Python package requires two pieces: the system\nlibraries and the Python bindings. While the latter is easily done\nwith `pip`/`poetry` and is included in the poetry.lock file, the former\ncan be complicated depending on your system. If you're lucky, there is\na pre-built package available from apt, apk, or yum. If you're not,\nsee below.\n\nKeep in mind that the minor version number of the GDAL system\nlibraries *must agree* with the minor version of the GDAL `pip`\npackage. If the `pip` package fails to install or load, it is highly\nlikely that you're trying to install a mismatched version.\n\nAlso know that while we so pin the GDAL version and keep it up to\ndate, an updated version isn't strictly a requirement. If you are\ndeveloping on a system where the most recent GDAL system libraries are\nnot available (e.g. Ubuntu bionic), feel free to install a lesser\nversion of GDAL for development purposes. You may be able to install a\ndifferent version and resolve the dependencies by executing something\nlike `poetry add GDAL==3.3`, but your mileage may vary.\n\nIf you prefer to build GDAL from source (not recommended), there is a\n`build_gdal.sh` script in the repo that does reasonably well. The\nspecifics in the script may need a bit of tweaking.\n\n\n#### Troubleshooting\n\nGDAL doesn't properly source its own lib paths when installing the python package, so we have to define\nthese environment variables:\n\n```bash\n$ export CPLUS_INCLUDE_PATH=/usr/include/gdal\n$ export C_INCLUDE_PATH=/usr/include/gdal\n```\n\n### `THREDDS` Data\nIf you plan to use a `THREDDS` server to provide the data you must set the root\nof the url in an environment variable.\n```\nexport THREDDS_URL_ROOT=https://marble-dev01.pcic.uvic.ca/twitcher/ows/proxy/thredds/catalog/datasets/\n```\n\n## Development\n\n### Installation\n\nSetup using `poetry` which sets up the virtual environment automatically.\n\n```bash\n$ poetry install # --with=dev to include development packages\n$ poetry shell\n```\n\nDevelopment packages are listed under\n`[tool.poetry.group.dev.dependencies]` in the `pyproject.toml` file.\n\n#### Pre-commit hook\nThe `pre-commit hook` will run checks against your code whenever you make a commit. This prevents styling from breaking the CI/CD actions pipeline. This will be automatically installed by the command above, but to do so manually run the following:\n```bash\n$ poetry add --group=dev pre-commit\n```\n\n### Building the Documentation\n\nYou can install documentation requirements, including [poethepoet](https://poethepoet.natn.io/) to automaticaly run documentaion scripts, with\n\n```bash\npoetry install --with docs\n```\n\nAnd then use poe to build the HTML documentation in the `doc/build/html` directory:\n\n```\npoe document\n```\n\nThere is also a poe command to generate PDF documentation.\n\n```\npoe pdf\n```\n\nIn order to correctly generate a PDF, you will need the following font packages installed on your system:\n* latexmk\n* texlive-latex-recommended\n* texlive-fonts-recommended\n* texlive-latex-extra\n\n### Running the dev server\n\nA development server can be run locally by using the Flask command line interface documented [here](http://flask.pocoo.org/docs/0.12/cli/). In general, you need to set one environment variable FLASK_APP=ce.wsgi:app and can optionally set FLASK_DEBUG=1 for live code reloading.\n\nDatabase dsn can be configured with the MDDB_DSN environment variable. Defaults to 'postgresql://httpd_meta@db.pcic.uvic.ca/pcic_meta'\n\nThe location of the precalculated regional datafiles is specified with the `REGION_DATA_DIRECTORY` environment variable.\n\n(venv)$ MDDB_DSN=postgresql://dbuser:dbpass@dbhost/dbname REGION_DATA_DIRECTORY=/storage/data/projects/comp_support/climate_explorer_data_prep/precalculated_regions/ FLASK_APP=ce.wsgi:app flask run -p \u003cport\u003e\n\n### Testing\n\n#### Within the virtual environment:\n\n```bash\npoetry run py.test -v\n```\n\n#### Using Docker container to test current directory:\n\n```bash\nsudo docker run --rm -it -v ${PWD}:/app --name backend-test pcic/climate-explorer-backend bash -c \"pip install pytest; py.test -v ce/tests\"\n```\n\n#### Using Docker container to test remote code changes:\n\n```bash\nsudo docker run --rm -it --name backend-test pcic/climate-explorer-backend bash -c \"apt-get update; apt-get install -yq git; git fetch; git checkout \u003ccommit-ish\u003e; pip install pytest; py.test -v ce/tests\"\n```\n\n### Setup using Docker:\nBuild the image manually:\n```bash\ngit clone https://github.com/pacificclimate/climate-explorer-backend\ncd climate-explorer-backend\ndocker build -t climate-explorer-backend-image -f docker/Dockerfile.dev .\n```\n\nIt's convenient to create a separate read-only docker container to mount the data. This container can be shared by multiple instances of the server backend. More `-v` arguments can be supplied as needed to bring together data from multiple locations, as long as individual files end up mapped onto the locations given for them in the metadata database.\n\nAutomated image build:\n\nGithub actions will automatically build and publish and image to our [docker hub](https://hub.docker.com/r/pcic/climate-explorer-backend) on each push and tag creation. The tagging strategy is defined by the [docker workflow](https://github.com/marketplace/actions/build-and-push-docker-images#tag_with_ref).\n\n```bash\ndocker run --name ce_data -v /absolute/path/to/wherever/the/needed/data/is/:/storage/data/:ro ubuntu 22.04\n```\n\nFinally run the climate explorer backend image as a new container.\n\n```bash\ndocker run -it -p whateverexternalport:8000\n               -e \"MDDB_DSN=postgresql://dbuser:dbpassword@host/databasename\"\n               -e \"REGION_DATA_DIRECTORY=/path/to/region/data\"\n               --volumes-from ce_data\n               --name climate-explorer-backend\n               climate-explorer-backend-image\n```\n\nIf you aren't using a read-only data container, replace `--volumes-from ce_data` with one or more `-v /absolute/path/to/wherever/the/needed/data/is/:/storage/data/` arguments.\n\nIf using the test data is sufficient, use `-e \"MDDB_DSN=sqlite:////app/ce/tests/data/test.sqlite\"` when running the container.\n\n## Releasing\n\nCreating a versioned release involves:\n\n1. Incrementing `__version__` in `setup.py`\n2. Summarize the changes from the last release in `NEWS.md`\n3. Commit these changes, then tag the release:\n\n  ```bash\ngit add setup.py NEWS.md\ngit commit -m\"Bump to version x.x.x\"\ngit tag -a -m\"x.x.x\" x.x.x\ngit push --follow-tags\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacificclimate%2Fclimate-explorer-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpacificclimate%2Fclimate-explorer-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpacificclimate%2Fclimate-explorer-backend/lists"}