ReferenceOffline Mode

Overview

The offline mode allows users to use the RunClient or to connect to an offline run persisted on a local path, outside of a Polyaxon cluster. When the offline mode is enabled , Polyaxon will perform all API and tracking related code locally without needing access to a Polyaxon API, and will persist any generated artifacts or API blobs locally.

Setting the offline mode

To configure the offline mode using the environment variable, users just need to set an environment variable POLYAXON_IS_OFFLINE to true/1.

export POLYAXON_IS_OFFLINE=true
# Or
export POLYAXON_IS_OFFLINE="1"

or in Python

import os

os.environ["POLYAXON_IS_OFFLINE"] = "true"
# Or
os.environ["POLYAXON_IS_OFFLINE"] = "1"

It's also possible to set the offline mode using the client directly:

from polyaxon.client import RunClient

...
run_client = RunClient(..., is_offline=True, ...)
...
run_client.log_inputs(foo="bar", key="value", param=2.3)
run_client.log_outputs(result1=11, result2="foo")
...
print(run_client.run_uuid)
print(run_client.run_data)
...
run_client.persist_run(path="/tmp/offline/")

or with the tracking Run class:

from polyaxon.tracking import Run

run = Run(..., is_offline=True, ...)
...
run.log_metrics(m1=2.3, m2=0.1, step=2)
run.log_outputs(result1=11, result2="foo")
...
print(run.run_uuid)
print(run.run_data)

or with the tracking module:

from polyaxon import tracking

tracking.init(..., is_offline=True, ...)
...
tracking.log_metrics(m1=2.3, m2=0.1, step=2)
tracking.log_outputs(result1=11, result2="foo")
...
print(tracking.TRACKING_RUN.run_uuid)
print(tracking.TRACKING_RUN.run_data)

Offline tracking

If you are running outside of a Polyaxon cluster:

from polyaxon import tracking

if __name__ == "__main__":
    # Uses the project from the local cache, otherwise raises.
    tracking.init(is_offline=True)

    ...

You can also provide the project manually:

from polyaxon import tracking

if __name__ == "__main__":
    tracking.init(project="owner/project", name="run1", is_offline=True)

    ...

Tracking multiple offline runs

If you need to track multiple offline runs:

from polyaxon import tracking

# Start run1
tracking.init(name="run1", is_new=True, is_offline=True)

# ...

# End run1
tracking.end()

# ...

# Start run2
tracking.init(project="owner/project2", name="run2", is_new=True, is_offline=True)

# ...

# End run2
tracking.end()

Resuming an offline run

If you are running outside of a Polyaxon cluster and you need to resume an offline run:

from polyaxon.client import RunClient

# Resume run
run_client = RunClient.load_offline_run(path="/tmp/offline", raise_if_not_found=True)
...
print(run_client.run_uuid)
print(run_client.run_data)
...

Using tracking:

from polyaxon import tracking

tracking.init(run_uuid="UUID_OF_THE_PREVIOUS_OFFLINE_RUN")