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
23 changes: 0 additions & 23 deletions .github/workflows/pylint.yml

This file was deleted.

8 changes: 3 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install ruff pytest
python -m pip install -e .
python -m pip install -e ".[dev]"
python -m pip install -e ".[test]"
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=F821,F401 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check
19 changes: 14 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@ repos:
# You are encouraged to use static refs such as tags, instead of branch name
#
# Running "pre-commit autoupdate" automatically updates rev to latest tag
rev: 0.13.1+ibm.61.dss
rev: 0.13.1+ibm.62.dss
hooks:
- id: detect-secrets # pragma: whitelist secret
additional_dependencies: [boxsdk<4]
# Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options.
# You may also run `pre-commit run detect-secrets` to preview the scan result.
# when "--baseline" without "--use-all-plugins", pre-commit scan with just plugins in baseline file
# when "--baseline" with "--use-all-plugins", pre-commit scan with all available plugins
# add "--fail-on-unaudited" to fail pre-commit for unaudited potential secrets
args: [--baseline, .secrets.baseline, --use-all-plugins]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.3
# Ruff version.
rev: v0.14.2
hooks:
# Run the linter.
- id: ruff-check
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or:
- python
- jupyter
types_or: [ python, pyi ]
- repo: https://github.com/mattlqx/pre-commit-sign
rev: v1.2.0
hooks:
- id: sign-commit
20 changes: 10 additions & 10 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2025-10-01T20:02:29Z",
"generated_at": "2025-10-28T12:40:55Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -81,21 +81,21 @@
{
"hashed_secret": "5810b71c07271f259208c5790992170ac1e13b37",
"is_verified": false,
"line_number": 437,
"line_number": 436,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "1c1dc227208cec78bbdb8d9247164879f908a9ad",
"is_verified": false,
"line_number": 482,
"line_number": 481,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "e57967bc8f018a30bb192717673876f0ebdbe5d9",
"is_verified": false,
"line_number": 558,
"line_number": 557,
"type": "Base64 High Entropy String",
"verified_result": null
}
Expand All @@ -104,41 +104,41 @@
{
"hashed_secret": "e52b18568a4fa073b958134ea5ec0f9407b6ebc3",
"is_verified": false,
"line_number": 352,
"line_number": 345,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "43cf2641021e5833120affd5a2bcdf35089eaf75",
"is_verified": false,
"line_number": 417,
"line_number": 410,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "78f9a422a3afb6ff5aff30094699c2b299dfd614",
"is_verified": false,
"line_number": 949,
"line_number": 942,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "2525429c7a93512ed0c4b799b867a83a6b19f7ff",
"is_verified": false,
"line_number": 1014,
"line_number": 1007,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "8915fab07d3bf85d3755089a7fc82e911405d40a",
"is_verified": false,
"line_number": 1080,
"line_number": 1073,
"type": "Base64 High Entropy String",
"verified_result": null
}
]
},
"version": "0.13.1+ibm.61.dss",
"version": "0.13.1+ibm.62.dss",
"word_list": {
"file": null,
"hash": null
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,33 @@ If users want to optimize hyperparameters:
terratorch iterate --hpo --config <config-file>
```

Another way to run terratorch-iterate is to omit `terratorch` by running:
```shell
iterate --hpo --config <config-file>
```

For instance:
```shell
terratorch iterate --hpo --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml
iterate --hpo --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml
```


If users want to rerun best experiment, please use the same config file. Additionally, the `parent_run_id`, which is the mlflow run id from optimization, should be added as shown below:
```shell
terratorch iterate --repeat --config <config-file> --parent_run_id <mlflow run_id from hpo>
iterate --repeat --config <config-file> --parent_run_id <mlflow run_id from hpo>
```
For instance:
```shell
terratorch iterate --repeat --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml --parent_run_id 61bdee4a35a94f988ad30c46c87d4fbd
iterate --repeat --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml --parent_run_id 61bdee4a35a94f988ad30c46c87d4fbd
```

If users want to optimize hyperparameters then the rerun best experiment in a single command, please use both settings as shown below:
```shell
terratorch iterate --hpo --repeat --config <config-file>
iterate --hpo --repeat --config <config-file>
```
For instance:
```shell
terratorch iterate --hpo --repeat --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml
iterate --hpo --repeat --config configs/dofa_large_patch16_224_upernetdecoder_true_modified.yaml
```

To check the experiment results, use `mlflow ui --host $(hostname -f) --port <port> --backend-store-uri <storage_uri>`
Expand All @@ -121,11 +126,11 @@ See `configs/summarize_results_template.yaml` in the git repo for an example.

To summarize results and hyperparameters, please run the following:
```shell
terratorch iterate --summarize --config <summarize-config-file>
iterate --summarize --config <summarize-config-file>
```
For instance:
```shell
terratorch iterate --summarize --config configs/summarize_results.yaml
iterate --summarize --config configs/summarize_results.yaml
```

The results and hyperparameters are extracted into a csv file. For example, if `storage_uri` is `/opt/benchmark_experiments/hpo`, then sumarized results will be saved in last file as shown below:
Expand Down
5 changes: 2 additions & 3 deletions plotting/plot_results_mlflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import json"
"import matplotlib.pyplot as plt"
]
},
{
Expand Down
9 changes: 1 addition & 8 deletions plotting/plot_results_repeated_runs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,18 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"GEO_BENCH_DIR\"] = \"/Users/cpi/terratorch\"\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"import pandas as pd\n",
"from pathlib import Path\n",
"import seaborn as sns\n",
"\n",
"import geobench as gb\n",
"\n",
"# from geobench_exp.experiment import parse_results\n",
"from matplotlib.ticker import FormatStrFormatter\n",
"import json\n",
"from scipy.stats import trim_mean\n",
"import plot_tools"
]
},
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ requires = ["setuptools >= 77.0.3"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["benchmark*"]
include = ["terratorch_iterate*"]

[project]

name = "terratorch-iterate"
version = "0.2.0"
requires-python = ">= 3.10"
version = "0.2.2rc1"
requires-python = ">= 3.11"
description = "A terratorch's plugin for benchmarking and hyperparameter optimization"
authors = [
{ name = "Carlos Gomes"},
Expand Down Expand Up @@ -61,6 +61,7 @@ dependencies = [
"more-itertools",
"importlib-metadata",
"numpy",
"mlflow",
"optuna",
"types-tabulate",
"ray",
Expand All @@ -69,7 +70,6 @@ dependencies = [
"opencv-python-headless",
"configspace",
"optuna-integration",
"seaborn",
"psutil",
"tabulate>=0.9.0",
]
Expand All @@ -86,7 +86,8 @@ dev = [
"mkdocstrings[python]",
"mike", # for building docs with versions
"tox",
"pre-commit"
"pre-commit",
"seaborn"
]

test = [
Expand Down
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def submit_job(
if tc_id is not None:
jbsub = f'bsub -e {err_file} -o {out_file} -M 40G -gpu "num=1/task:mode=exclusive_process:gmodel=NVIDIAA100_SXM4_80GB" pytest -vv tests/integration/test_main.py::test_main[{tc_id}]'
elif config is not None:
jbsub = f'bsub -e {err_file} -o {out_file} -M 40G -gpu "num=1/task:mode=exclusive_process:gmodel=NVIDIAA100_SXM4_80GB" terratorch iterate --hpo --config {config}'
jbsub = f'bsub -e {err_file} -o {out_file} -M 40G -gpu "num=1/task:mode=exclusive_process:gmodel=NVIDIAA100_SXM4_80GB" iterate --hpo --config {config}'
else:
raise ValueError("Error! Either tc_id or config must be not None")
cmd = jbsub.split()
Expand Down
1 change: 1 addition & 0 deletions terratorch_iterate/backbone_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def benchmark_backbone(
mlflow.set_tracking_uri(storage_uri)
logger.info(f"Setting experiment name: {experiment_name}")
mlflow.set_experiment(experiment_name)
experiment_id = mlflow.get_experiment_by_name(experiment_name).experiment_id

optimization_space = parse_optimization_space(optimization_space)

Expand Down
Loading