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

Feat/improve pypi packaging #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# also see
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates

version: 2
updates:
# Workflow files in .github/workflows will be checked
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

10 changes: 10 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Linting
on: [pull_request, push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
41 changes: 41 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
release:
types:
- created

permissions:
contents: read

jobs:
check-package:
name: Build & inspect our package.
runs-on: ubuntu-latest
if: ${{ github.repository }} == 'openearth/coclico-workbench'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

release-pypi:
permissions:
id-token: write
contents: read
name: Publish released package to pypi.org
environment: release-pypi
runs-on: ubuntu-latest
needs: check-package

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ dist*

# duckdb
*:memory*

src/coclico/_version.py
*.vscode*
23 changes: 16 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
ci:
autofix_prs: false
autofix_prs: true
autoupdate_schedule: weekly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: debug-statements
- id: check-json
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: pretty-format-json
exclude: '\.ipynb$'
- id: sort-simple-yaml

- repo: https://github.com/psf/black
rev: 23.7.0

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: black
language_version: python3.11
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
22 changes: 0 additions & 22 deletions .vscode/settings.json

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ CoCliCo workbench prototype repository with tutorials & exploratory tools for Co

Notebooks can be opened in Google Colab. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/openearth/coclico-workbench)

## Coding offline in the Workbench Environment
## Coding offline in the Workbench Environment

Please follow the instructions to install the CoCliCo environment as outlined in the [CoCliCo Data](https://github.com/openearth/coclicodata) repository.
After step 13, please return to the instructions here again and clone the `coclico-workbench` repo by adding ("Add" --> "clone repository" --> "URL") URL in GitHub Desktop. You can find the URL under the green "code" button at the top of this repo. Please change the local path to something like: C:\Users\***\Documents\GitHub (where you create the GitHub folder yourself). The repo will be cloned here.

Next, open VS Code and select the cloned `coclico-workbench` folder as your working directory. As a test, you can open `IPCC_AR5_AR6_comparison.ipynb` in notebooks. Select your kernel (the `coclicodata` env) in the top right corner and run cells by pressing shift-enter. You should be able to progress through the notebook without any errors.
Next, open VS Code and select the cloned `coclico-workbench` folder as your working directory. As a test, you can open `IPCC_AR5_AR6_comparison.ipynb` in notebooks. Select your kernel (the `coclicodata` env) in the top right corner and run cells by pressing shift-enter. You should be able to progress through the notebook without any errors.

Might you run into trouble with these installation guidelines, please reach out to [@EtienneKras](https://github.com/EtienneKras), [@mathvansoest](https://github.com/mathvansoest) or [@FlorisCalkoen](https://github.com/FlorisCalkoen) for help.
Might you run into trouble with these installation guidelines, please reach out to [@EtienneKras](https://github.com/EtienneKras), [@mathvansoest](https://github.com/mathvansoest) or [@FlorisCalkoen](https://github.com/FlorisCalkoen) for help.

## Repository structure

Expand All @@ -23,7 +23,7 @@ Might you run into trouble with these installation guidelines, please reach out

- **tutorials**: short notebooks describing how to use the CoCliCo Data repository (STAC)

- **src/coclicodata**: (OUTDATED) various scripts with basic functionalities that can be used for the tutorials & exploratory tools
- **src/coclicodata**: (OUTDATED) various scripts with basic functionalities that can be used for the tutorials & exploratory tools

## Contributing

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# -- Project information -----------------------------------------------------

project = u"coclico"
copyright = u"2022, Floris Calkoen"
author = u"Floris Calkoen"
project = "coclico"
copyright = "2022, Floris Calkoen"
author = "Floris Calkoen"

# -- General configuration ---------------------------------------------------

Expand Down
88 changes: 44 additions & 44 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Example usage\n",
"\n",
"To use `coclico` in a project:"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"import coclico\n",
"\n",
"print(coclico.__version__)"
],
"outputs": [],
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example usage\n",
"\n",
"To use `coclico` in a project:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import coclico\n",
"\n",
"print(coclico.__version__)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
12 changes: 6 additions & 6 deletions notebooks/IPCC_AR5_AR6_comparison.html
Original file line number Diff line number Diff line change
Expand Up @@ -7841,7 +7841,7 @@ <h3 id="Geospatial-plot">Geospatial plot<a class="anchor-link" href="#Geospatial
<span class="n">plt</span><span class="o">.</span><span class="n">gcf</span><span class="p">()</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">left</span><span class="o">=</span><span class="mf">0.05</span><span class="p">)</span>

<span class="c1"># populate AR5 plot</span>
<span class="n">ax1</span><span class="o">.</span><span class="n">set_facecolor</span><span class="p">((</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="n">ax1</span><span class="o">.</span><span class="n">set_facecolor</span><span class="p">((</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="n">im5</span> <span class="o">=</span> <span class="n">ar5_item</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
<span class="n">ax</span><span class="o">=</span><span class="n">ax1</span><span class="p">,</span>
<span class="n">add_colorbar</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
Expand Down Expand Up @@ -7998,11 +7998,11 @@ <h3 id="Temporal-plot">Temporal plot<a class="anchor-link" href="#Temporal-plot"
<span class="c1"># 2014 data (related to AR5, in m)</span>
<span class="n">WGHL_2030l</span> <span class="o">=</span> <span class="mf">0.1</span>
<span class="n">WGHL_2030h</span> <span class="o">=</span> <span class="mf">0.25</span>
<span class="n">GLGH_2050l</span> <span class="o">=</span> <span class="mf">0.15</span>
<span class="n">GLGH_2050l</span> <span class="o">=</span> <span class="mf">0.15</span>
<span class="n">GLGH_2050h</span> <span class="o">=</span> <span class="mf">0.3</span>
<span class="n">GLGH_2085l</span> <span class="o">=</span> <span class="mf">0.25</span>
<span class="n">GLGH_2085h</span> <span class="o">=</span> <span class="mf">0.6</span>
<span class="n">WLWH_2050l</span> <span class="o">=</span> <span class="mf">0.2</span>
<span class="n">WLWH_2050l</span> <span class="o">=</span> <span class="mf">0.2</span>
<span class="n">WLWH_2050h</span> <span class="o">=</span> <span class="mf">0.4</span>
<span class="n">WLWH_2085l</span> <span class="o">=</span> <span class="mf">0.45</span>
<span class="n">WLWH_2085h</span> <span class="o">=</span> <span class="mf">0.8</span>
Expand All @@ -8026,7 +8026,7 @@ <h3 id="Temporal-plot">Temporal plot<a class="anchor-link" href="#Temporal-plot"
<span class="c1"># pre-processing function</span>
<span class="k">def</span> <span class="nf">preprocess</span><span class="p">(</span><span class="n">ds</span><span class="p">):</span>
<span class="n">point_geom</span> <span class="o">=</span> <span class="n">shapely</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">point_location</span><span class="p">)</span>

<span class="n">ds</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">ds</span><span class="o">.</span><span class="n">rio</span><span class="o">.</span><span class="n">clip</span><span class="p">([</span><span class="n">point_geom</span><span class="p">])</span>
<span class="o">.</span><span class="n">sel</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">point_location</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">y</span><span class="o">=</span><span class="n">point_location</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">method</span><span class="o">=</span><span class="s2">"nearest"</span><span class="p">)</span>
Expand Down Expand Up @@ -8137,7 +8137,7 @@ <h3 id="Temporal-plot">Temporal plot<a class="anchor-link" href="#Temporal-plot"
<span class="n">ax1</span><span class="o">.</span><span class="n">vlines</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="mf">2030.2</span><span class="p">,</span> <span class="n">ymin</span><span class="o">=</span><span class="n">WGHL_2030l</span><span class="p">,</span> <span class="n">ymax</span><span class="o">=</span><span class="n">WGHL_2030h</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="s2">"AR5-RCP-8.5"</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s2">":"</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.8</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"KNMI'14 - RCP8.5 (W) low-high"</span><span class="p">)</span>
<span class="n">ax1</span><span class="o">.</span><span class="n">vlines</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="mf">2050.2</span><span class="p">,</span> <span class="n">ymin</span><span class="o">=</span><span class="n">WLWH_2050l</span><span class="p">,</span> <span class="n">ymax</span><span class="o">=</span><span class="n">WLWH_2050h</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="s2">"AR5-RCP-8.5"</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s2">":"</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.8</span><span class="p">)</span>
<span class="n">ax1</span><span class="o">.</span><span class="n">vlines</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="mf">2085.2</span><span class="p">,</span> <span class="n">ymin</span><span class="o">=</span><span class="n">WLWH_2085l</span><span class="p">,</span> <span class="n">ymax</span><span class="o">=</span><span class="n">WLWH_2085h</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="s2">"AR5-RCP-8.5"</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s2">":"</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.8</span><span class="p">)</span>

<span class="n">ax1</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="s2">"upper left"</span><span class="p">)</span>

<span class="c1"># AR6</span>
Expand Down Expand Up @@ -8256,7 +8256,7 @@ <h3 id="Export-notebook">Export notebook<a class="anchor-link" href="#Export-not
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-ipython3"><pre><span></span>
<div class="highlight hl-ipython3"><pre><span></span>
</pre></div>
</div>
</div>
Expand Down
Loading
Loading