Skip to content
Merged
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
9 changes: 6 additions & 3 deletions .github/workflows/TestWithSinglePython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:

runs-on: ubuntu-latest

env:
# PyPI's simple index occasionally returns transient 5xx responses.
# Retry more aggressively than pip's default before failing the job.
PIP_RETRIES: "10"
PIP_TIMEOUT: "60"

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -35,9 +41,6 @@ jobs:
pip install numpy
pip install setuptools
pip install pytest_mock
- name: Install avaframe
run: |
pip install avaframe
- name: Install debrisframe
run: |
pip install .
Expand Down
2 changes: 1 addition & 1 deletion debrisframe/runC1TIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def runC1TIF(debrisDir="", inHydr=False):
initProj.cleanSingleAvaDir(debrisDir, deleteOutput=False)

# load debris flow config
DebrisCfg = cfgUtils.getModuleConfig(c1TIF)
DebrisCfg = cfgUtils.getModuleConfig(c1TIF, debrisDir, toPrint=False)

# ---------------------
# check if in2TopoHyd computes input data for c1TIF
Expand Down
23 changes: 23 additions & 0 deletions debrisframe/tests/test_c1TIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from debrisframe.c1TIF import c1TIF
from debrisframe import runC1TIF

from avaframe.in3Utils import cfgUtils

Expand Down Expand Up @@ -48,3 +49,25 @@ def test_runC1TIF(tmp_path):
assert simDF["rho"].iloc[0] == 1000
assert simDF["explicitFriction"].iloc[0] == 0
assert simDF["frictModel"].iloc[0] == "Voellmy"


def test_runC1TIF_expertCfg(tmp_path):
"""Expert Inputs/CFGs/c1TIFCfg.ini must take effect in runC1TIF"""

testDir = pathlib.Path(__file__).parents[0]
inputDir = testDir / "data" / "testC1TIF"
avaDir = pathlib.Path(tmp_path, "testC1TIF")
shutil.copytree(inputDir, avaDir)

cfgDir = avaDir / "Inputs" / "CFGs"
cfgDir.mkdir(parents=True)
expertCfg = cfgDir / "c1TIFCfg.ini"
expertCfg.write_text("[com1DFA_com1DFA_override]\nrho = 3000\n")

runC1TIF.runC1TIF(str(avaDir))

# expert config survives cleanSingleAvaDir (Review Focus 4)
assert expertCfg.is_file()
# override was read from Inputs/CFGs, not the packaged default (Review Focus 1, 5)
simDF, _ = cfgUtils.readAllConfigurationInfo(str(avaDir))
assert int(simDF["rho"].iloc[0]) == 3000
52 changes: 52 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,57 @@ change into your ``debrisframe`` directory (replace ``[YOURDIR]`` with your path
pixi run python runC1TIF.py


.. _installationFromQGis:

From QGIS
^^^^^^^^^

DebrisFrame can be run from QGIS via the OpenNHMQGisConnector plugin. The plugin
installs the required Python packages into QGIS's Python environment and adds
the DebrisFrame modules in the QGIS Processing Toolbox.

Install the connector from ZIP
""""""""""""""""""""""""""""""""

The connector version required for DebrisFrame is not available on
`plugins.qgis.org <https://plugins.qgis.org>`_ yet and is distributed as a zip
file instead.

#. Get the ``OpenNHMQGisConnector.zip``.
#. In QGIS, open ``Plugins > Manage and Install Plugins...`` and switch to the
``Install from ZIP`` tab.
#. Select the downloaded zip file and click ``Install Plugin``.
#. Make sure the plugin is enabled in the ``Installed`` tab.

Install the DebrisFrame package
""""""""""""""""""""""""""""""""""""""""

#. Open the Processing Toolbox (``Processing > Toolbox``).
#. Expand ``OpenNHM > Admin`` and run ``Install DebrisFrame``.

The tool installs the ``debrisframe`` package from PyPI. DebrisFrame requires
AvaFrame ``>= 2.2b1``. Since ``2.2b1`` is a pre-release, pip does not install it
by default. The tool installs AvaFrame with the ``--pre`` flag. If an
older AvaFrame is already installed, you are asked before it is replaced.

If you prefer to install AvaFrame 2.2b1 yourself, or if the installation via the
tool fails, run::

python -m pip install --user --upgrade --pre avaframe

On Windows, open the **OSGeo4W Shell** from the start menu and run the command there.
If you have multiple QGIS versions installed, choose the OSGeo4W Shell that matches
your QGIS version.

Restart QGIS afterwards for the DebrisFrame tools to appear.

Run a module
""""""""""""

After restarting QGIS, the DebrisFrame tools appear in the Processing Toolbox
under ``DebrisFrame_Experimental``. See :ref:`workflow:Application via QGIS` for
an overview of the available modules and how to run them.




5 changes: 3 additions & 2 deletions docs/source/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ Then run ::
Application via QGIS
---------------------

.. Note::
This documentation will be added soon!
Install the QGIS connector and DebrisFrame as described in
:ref:`installationFromQGis`. After restarting QGIS, the DebrisFrame tools appear
in the Processing Toolbox under ``DebrisFrame_Experimental``.


Relevant parameters
Expand Down
Loading