Skip to content

bug(core/singletask): TypeError crash and stale BASE_MODEL_URL when initial_model_url is omitted from YAML #574

Description

@g-k-s-03

What happened:
SingleTaskLearning._train() unconditionally assigns
os.environ["BASE_MODEL_URL"] = initial_model where initial_model is
obtained via kwargs.get("initial_model_url"). When initial_model_url
is absent from the algorithm YAML (a documented optional field in the
LLM-agent example), this value is None. Assigning None to os.environ
raises:

TypeError: str expected, not NoneType

Additionally, when multiple test cases run sequentially in the same
process via testcase.py, a stale BASE_MODEL_URL from a prior test
case that had initial_model_url set can persist into subsequent test
cases that omit it, causing the wrong pretrained checkpoint to be
loaded silently without any error.

What you expected to happen:
When initial_model_url is absent from the YAML, BASE_MODEL_URL should
not be set. If a prior test case had set it, the value should be
cleared before the next test case runs to prevent cross-test-case
environment pollution.

How to reproduce it:

  1. Use an algorithm YAML with initial_model_url commented out:

    basemodel:
    url: ...

    initial_model_url: (omitted)

  2. Run any single-task learning benchmark:

    python ianvs/main.py -f benchmarkingjob.yaml

  3. Observe the crash:

    TypeError: str expected, not NoneType
    at singletask_learning.py line 120

Anything else we need to know:

Files involved:

  • core/testcasecontroller/algorithm/paradigm/singletask_learning/singletask_learning.py

    • Line 51: self.initial_model = kwargs.get("initial_model_url") returns None if absent
    • Line 120: os.environ["BASE_MODEL_URL"] = initial_model crashes when None
  • core/testcasecontroller/testcase/testcase.py

    • Sequential test-case execution in the same process makes stale
      env pollution a real cross-test-case issue

Proposed fix — guard the assignment in _train():

if initial_model is not None:
    os.environ["BASE_MODEL_URL"] = initial_model
else:
    os.environ.pop("BASE_MODEL_URL", None)

The pop with a default clears any stale value from a prior test case.

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions