Skip to content

Lazy environment loading uses incorrect path <env>/.json instead of <env>.json #1141

@SxxAq

Description

@SxxAq

Lazy environment loading appears to construct the on-disk path incorrectly in two places, causing Visdom to look for:

<env_path>/<eid>/.json

instead of the file layout used elsewhere in the codebase:

<env_path>/<eid>.json

This can prevent environments that are not already loaded in memory from being loaded from disk correctly.

Affected code

The issue appears in these locations:

  • py/visdom/utils/server_utils.py in compare_envs
  • py/visdom/utils/server_utils.py in load_env

Current code uses:

p = os.path.join(env_path, eid.strip(), ".json")

which resolves to a directory-style path such as:

~/.visdom/main/.json

Why this looks incorrect

Other parts of the codebase consistently use flat JSON files named <env>.json:

  • serialize_env writes to:
os.path.join(env_path, "{0}.json".format(env_id))
  • environment deletion also assumes:
os.path.join(self.env_path, "{0}.json".format(msg["eid"]))
  • app startup scans env_path for *.json files directly

So the lazy-load path shape seems inconsistent with how environments are actually stored.

Expected behavior

When a saved environment is not already loaded in memory, Visdom should attempt to load it from:

<env_path>/<eid>.json

Actual behavior

Visdom appears to try loading from:

<env_path>/<eid>/.json

which does not match the storage format used elsewhere.

Suggested fix

Replace:

os.path.join(env_path, eid.strip(), ".json")

with something like:

os.path.join(env_path, "{}.json".format(eid.strip()))

in both compare_envs and load_env.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions