Commit 31e70c01 authored by Joachim Folz's avatar Joachim Folz
Browse files

change Run.add_metrics from kwargs to dict

parent 0d0b99ca
Loading
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Interpret None values as NULL in *_set_* methods
- Docopt: add dash to argument type suffixes, e.g., "*-int"
- Run.add_metrics: accept metrics only as dictionary
### Added
- Add "extras" columns to experiments and runs
- Add "name" attribute to Experiment class
+13 −3
Changes for sqltrack/model.py: 13 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -656,9 +656,19 @@ def run_remove_extras(
        cursor.execute(query, (list(extras), run_id))


def run_add_metrics(client: Client, run_id: int, step: int = 0, progress: float = 0.0, **metrics):
def run_add_metrics(
    client: Client,
    run_id: int,
    metrics: dict,
    step: int = 0,
    progress: float = 0.0,
):
    """
    Add metrics to a run.

    Important:
        Either ``step`` or ``progress`` need to be a non-zero value
        to avoid overwriting existing metric values.
    """
    query = f"""
        INSERT INTO metrics(run_id, step, progress, {", ".join(metrics)})
@@ -914,17 +924,17 @@ class Run:

    def add_metrics(
        self,
        metrics: dict,
        step: int = 0,
        progress: float = 0.0,
        updated: Union['auto', datetime, None] = 'auto',
        **metrics,
    ) -> Run:
        """
        Add metrics to the run.
        See :py:func:`run_add_metrics` for details.
        """
        with self.client.connect():
            run_add_metrics(self.client, self.id, step, progress, **metrics)
            run_add_metrics(self.client, self.id, metrics, step, progress)
            self.set_updated(updated)
        return self