Skip to content

Commit

Permalink
Merge pull request #110 from swisstopo/repo-in-mlflow
Browse files Browse the repository at this point in the history
Tag git branch and last commit in MLFlow
  • Loading branch information
stijnvermeeren-swisstopo authored Jan 22, 2025
2 parents e7f76aa + b823ca0 commit b5ef183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ lint = [
"pre-commit==3.6.2",
]
experiment-tracking = [
"mlflow==2.11.1"
"mlflow==2.11.1",
"pygit2"
]
visualize = [
"matplotlib==3.8.0"
Expand Down
9 changes: 8 additions & 1 deletion src/stratigraphy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
mlflow_tracking = os.getenv("MLFLOW_TRACKING") == "True" # Checks whether MLFlow tracking is enabled
if mlflow_tracking:
import mlflow
import pygit2

logging.basicConfig(format="%(asctime)s %(levelname)-8s %(message)s", level=logging.INFO, datefmt="%Y-%m-%d %H:%M:%S")
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -147,7 +148,7 @@ def setup_mlflow_tracking(
out_directory: Path = None,
predictions_path: Path = None,
metadata_path: Path = None,
experiment_name: str = "Boreholes Stratigraphy",
experiment_name: str = "Boreholes data extraction",
):
"""Set up MLFlow tracking."""
mlflow.set_experiment(experiment_name)
Expand All @@ -163,6 +164,12 @@ def setup_mlflow_tracking(
mlflow.log_params(flatten(line_detection_params))
mlflow.log_params(flatten(matching_params))

repo = pygit2.Repository(".")
commit = repo[repo.head.target]
mlflow.set_tag("git_branch", repo.head.shorthand)
mlflow.set_tag("git_commit_message", commit.message)
mlflow.set_tag("git_commit_sha", commit.id)


def start_pipeline(
input_directory: Path,
Expand Down

1 comment on commit b5ef183

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/stratigraphy
   __init__.py8188%11
   extract.py1671670%3–446
   get_files.py19190%3–47
   main.py1261260%3–333
src/stratigraphy/benchmark
   metrics.py594229%22–25, 29–32, 36–39, 46–49, 53–54, 58, 65–74, 78–91, 96–133
src/stratigraphy/data_extractor
   data_extractor.py76495%32, 45, 120, 164
   utility.py6350%28–36
src/stratigraphy/depth
   a_to_b_interval_extractor.py371559%41–60, 79, 92
   depthcolumnentry_extractor.py23291%45–46
   interval.py1015249%25–28, 33–36, 42, 48, 52, 91–137, 158, 164–180
src/stratigraphy/depths_materials_column_pairs
   bounding_boxes.py301067%23, 32, 50, 60, 72–78
   material_description_rect_with_sidebar.py18856%27–40
src/stratigraphy/evaluation
   evaluation_dataclasses.py491178%52, 71–74, 90, 104, 125–131, 147
   groundwater_evaluator.py48198%77
   layer_evaluator.py664630%29–30, 35–39, 47, 69–95, 105–113, 128–149
   metadata_evaluator.py371462%46–65, 86–93
   utility.py16756%43–52
src/stratigraphy/groundwater
   groundwater_extraction.py1469038%52, 94, 137–148, 180–184, 199–215, 226–314, 335–363
   utility.py423614%10–17, 30–50, 62–76, 91–105
src/stratigraphy/layer
   layer.py371365%26, 29, 37, 52–72
src/stratigraphy/lines
   geometric_line_utilities.py86298%81, 131
   line.py51492%25, 50, 60, 110
   linesquadtree.py46198%75
src/stratigraphy/metadata
   coordinate_extraction.py106496%29, 93–94, 106
   elevation_extraction.py906033%34–39, 47, 55, 63, 79–87, 124–138, 150–153, 165–197, 212–220, 234–238
   language_detection.py181328%17–23, 37–45
   metadata.py662464%27, 83, 101–127, 146–155, 195–198, 206
src/stratigraphy/sidebar
   a_above_b_sidebar.py963959%40, 43, 58–66, 71, 78, 99, 104–111, 141–142, 184–225
   a_above_b_sidebar_validator.py411954%48, 58, 61, 63, 83–86, 111–129, 141–145
   a_to_b_sidebar.py431467%36, 49–50, 67, 95–108
   layer_identifier_sidebar.py462937%46–65, 81–97, 109, 122
   layer_identifier_sidebar_extractor.py292031%31–41, 55–75
   sidebar.py38392%41, 46, 87
   sidebarentry.py20385%27, 31, 43
src/stratigraphy/text
   description_block_splitter.py70297%24, 139
   extract_text.py29390%19, 53–54
   find_description.py41880%26–34, 111–114
   textblock.py901188%22, 27, 39, 44, 71, 79, 104, 116, 139, 160, 189
src/stratigraphy/util
   dataclasses.py32391%37–39
   predictions.py723453%72, 95–115, 143–187
   util.py341265%69–76, 90–92, 116–117
TOTAL238697559% 

Tests Skipped Failures Errors Time
101 0 💤 0 ❌ 0 🔥 7.665s ⏱️

Please sign in to comment.