Hectiq Lab

Results and errors

hectiqlab never lets an API that is down, slow or refusing crash your training. A call that fails in the network returns its failure as a value, and you choose what to do with it. A mistake in the call itself raises at once.

Reads and changes return a Result

import hectiqlab as hl

found = hl.datasets.get("interactions")

A Result is either Ok, holding the value, or Err, holding the error:

MethodDescription
unwrap()The value, or raises the error.
unwrap_or(default)The value, or default.
or_log(msg)The value, or logs the error as a warning and returns None.
is_ok(), is_err()Which one it is.
errorThe error, or None.
data = hl.datasets.get("interactions").unwrap()          # stop if it isn't there
runs = hl.runs.list(tags=["ENG-42"]).unwrap_or([])       # carry on without
hl.runs.update(title="Baseline").or_log("rename")        # warn and carry on

hl.datasets.resolve and hl.datasets.verify, and the same on hl.models, return a Result too.

Uploads and downloads return a Future

hl.artifacts.create, hl.datasets.create and hl.models.create, and each download, return a standard concurrent.futures.Future at once. .result() waits and gives the record, or raises the error.

An upload made while a run is open holds the run open until it lands, so you don't need to wait for it yourself.

What a run couldn't record

add_metric, stages and uploads never raise when the API fails. What didn't land is reported once, as a LabWarning, when the run ends:

LabWarning: hectiqlab: run 'My first run' did not record everything — ...

To raise it instead, call result() on the run:

with hl.run("My first run") as run:
    ...
run.result()

What raises at once

A call that can't be right raises before anything is sent, with a LabValidationError:

  • a metric, a stage or an artifact with no run open;
  • an unknown category or status;
  • no project named anywhere, or one not shaped organisation/name;
  • an artifact path that isn't a file.

Errors

Every error is a LabError, and carries status, the HTTP status the API answered, or None.

ErrorWhen
LabConnectionErrorThe API couldn't be reached, or didn't answer in time.
LabAuthErrorThere is no key, or the API refused it.
LabNotFoundErrorWhat was asked for doesn't exist.
LabValidationErrorThe arguments are invalid, to the API or already to hectiqlab.
LabServerErrorThe API failed on its side.

All are importable from hectiqlab.

On this page