-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update dev environment * Pixi toml update and settings * Update miniforge path workflows * Rounding due to numpy 2.0 * Add Dockerfile * Update .gitignore * Add cli to api.py * Update pixi.toml * Add custom inventory fetch (until fix in quartodoc) * Moved old stuff to archive * Update .gitignore * Update pixi.toml * Update pixi.toml * Remove fiat env * Add quarto for cli use * Add description * Add docker workflow * Add run section to docker workflow * Update docker workflow * Update docker workflow * Docker check mod * chown * sudo * sudo * ls * docker test * docker test * docker test * Working docker workflow * Working docker workflow * Added data gen task * Updated docs with docker page; reorganized a little * Updating the docs * Adjusted docs workflow * Api gen message * Replace tmpdir w/ tmp_path * Adjust test func name * Stop support python 3.9 * Update changelog
- Loading branch information
Showing
39 changed files
with
629 additions
and
154 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.yaml text eol=lf | ||
*.yml text eol=lf | ||
|
||
# GitHub syntax highlighting | ||
pixi.lock linguist-language=YAML# GitHub syntax highlighting | ||
pixi.lock linguist-language=YAML linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: Docker testing | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
docs: | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
include: | ||
- os: ubuntu-latest | ||
label: linux-64 | ||
|
||
name: ${{ matrix.label }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build docker image | ||
run: | | ||
docker build -f Dockerfile --build-arg="PIXIENV=default" --build-arg="UID=1001" -t fiat . | ||
- name: Execute docker container | ||
uses: addnab/docker-run-action@v3 | ||
with: | ||
username: deltares | ||
options: -v ${{ github.workspace }}/.testdata:/home/deltares/data | ||
shell: bash | ||
image: fiat:latest | ||
run: | | ||
pixi run python -m pip install tomli-w | ||
pixi run python data/create_test_data.py | ||
pixi run fiat run data/geom_event.toml | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ __pycache__/ | |
tmp/ | ||
whl/ | ||
|
||
# pixi environments | ||
.pixi | ||
pixi.lock | ||
*.egg-info | ||
|
||
# C extensions | ||
*.so | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM debian:bookworm-slim as base | ||
ARG PIXIENV | ||
ARG UID=1000 | ||
RUN apt-get update && apt-get install -y curl | ||
|
||
RUN useradd deltares | ||
RUN usermod -u ${UID} deltares | ||
USER deltares | ||
WORKDIR /home/deltares | ||
|
||
RUN curl -fsSL https://pixi.sh/install.sh | bash | ||
ENV PATH=/home/deltares/.pixi/bin:$PATH | ||
COPY pixi.toml pyproject.toml README.md ./ | ||
COPY --chown=deltares:deltares src/fiat ./src/fiat | ||
|
||
RUN chmod u+x src/ \ | ||
&& pixi run -e ${PIXIENV} install-fiat \ | ||
&& rm -rf .cache \ | ||
&& find .pixi -type f -name "*.pyc" -delete | ||
|
||
# Workaround: write a file that runs pixi with correct environment. | ||
# This is needed because the argument is not passed to the entrypoint. | ||
ENV RUNENV="${PIXIENV}" | ||
RUN echo "pixi run --locked -e ${RUNENV} \$@" > run_pixi.sh \ | ||
&& chown deltares:deltares run_pixi.sh \ | ||
&& chmod u+x run_pixi.sh | ||
ENTRYPOINT ["sh", "run_pixi.sh"] | ||
CMD ["fiat","info"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import click | ||
import sphobjinv as soi | ||
import yaml | ||
from pathlib import Path | ||
from quartodoc import convert_inventory | ||
from quartodoc.interlinks import inventory_from_url | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@click.command( | ||
short_help="Generate inventory files that the Quarto " | ||
"`interlink` extension can use to auto-link to other docs." | ||
) | ||
@click.argument("config", default="_quarto.yml") | ||
@click.option("--dry-run", is_flag=True, default=False) | ||
@click.option("--fast", is_flag=True, default=False) | ||
def interlinks(config, dry_run, fast): | ||
""" | ||
Generate inventory files that the Quarto `interlink` extension can use to | ||
auto-link to other docs. | ||
The files are stored in a cache directory, which defaults to _inv. | ||
The Quarto extension `interlinks` will look for these files in the cache | ||
and add links to your docs accordingly. | ||
""" | ||
|
||
# config loading ---- | ||
cfg = yaml.safe_load(open(config)) | ||
interlinks = cfg.get("interlinks", {}) | ||
|
||
p_root = Path(config).parent | ||
|
||
if not interlinks: | ||
print("No interlinks field found in your quarto config. Quitting.") | ||
return | ||
|
||
# interlinks config settings ---- | ||
cache = p_root / "_inv" | ||
cfg_fast = interlinks.get("fast", False) | ||
|
||
fast = cfg_fast or fast | ||
|
||
for k, v in interlinks["sources"].items(): | ||
# don't include user's own docs (users don't need to specify their own docs in | ||
# the interlinks config anymore, so this is for backwards compat). | ||
if v["url"] == "/": | ||
continue | ||
|
||
url = v["url"] + v.get("inv", "objects.inv") | ||
|
||
inv = inventory_from_url(url) | ||
|
||
p_dst = cache / f"{k}_objects" | ||
p_dst.parent.mkdir(exist_ok=True, parents=True) | ||
|
||
if fast: | ||
# use sphobjinv to dump inv in txt format | ||
df = inv.data_file() | ||
soi.writebytes(p_dst.with_suffix(".txt"), df) | ||
|
||
else: | ||
# old behavior of converting to custom json format | ||
convert_inventory(inv, p_dst.with_suffix(".json")) | ||
|
||
|
||
cli.add_command(interlinks) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
Oops, something went wrong.