diff --git a/.github/workflows/TestWithSinglePython.yml b/.github/workflows/TestWithSinglePython.yml index e5dbf8e..554cb2a 100644 --- a/.github/workflows/TestWithSinglePython.yml +++ b/.github/workflows/TestWithSinglePython.yml @@ -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: @@ -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 . diff --git a/debrisframe/runC1TIF.py b/debrisframe/runC1TIF.py index 9e78fd8..cddbf92 100644 --- a/debrisframe/runC1TIF.py +++ b/debrisframe/runC1TIF.py @@ -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 diff --git a/debrisframe/tests/test_c1TIF.py b/debrisframe/tests/test_c1TIF.py index 246eb5a..596946e 100644 --- a/debrisframe/tests/test_c1TIF.py +++ b/debrisframe/tests/test_c1TIF.py @@ -9,6 +9,7 @@ import pytest from debrisframe.c1TIF import c1TIF +from debrisframe import runC1TIF from avaframe.in3Utils import cfgUtils @@ -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 diff --git a/docs/source/installation.rst b/docs/source/installation.rst index f492252..7a6d12c 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -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 `_ 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. + + diff --git a/docs/source/workflow.rst b/docs/source/workflow.rst index d821b4e..fe1870e 100644 --- a/docs/source/workflow.rst +++ b/docs/source/workflow.rst @@ -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