Skip to content

blackfish run --dry-run crashes for local profiles #530

Description

@cswaney

For a local profile, blackfish run --dry-run fails with:

AttributeError: 'NoneType' object has no attribute 'hex'

The Slurm dry-run branch constructs its service with an explicit id, but the local branch does not:

# Slurm branch — lib/src/blackfish/cli/services/text_generation.py
service = TextGeneration(
    id=uuid4(),          # <- present
    name=name,
    ...
)

# local branch
service = TextGeneration(
    name=name,           # <- no id
    ...
)

render_job_script then does uuid=self.id.hex (server/services/base.py), and self.id is None because the object was never flushed to a database. Both text_generation.py and speech_recognition.py have the same asymmetry.

Reproduced on main:

r = CliRunner().invoke(main, ["run","-p","default","text-generation","openai/gpt-2","--dry-run"])
# exit: 1, exc: AttributeError("'NoneType' object has no attribute 'hex'")

Why the tests miss it

tests/cli/test_cli_run.py::test_dry_run_local_profile patches the service class entirely:

mock_service.render_job_script.return_value = "#!/bin/bash\necho test"

so the real render_job_script never runs. The test asserts on the echoed metadata lines above the script, which are produced before the crash would occur. Any test that mocks the renderer cannot catch a bug in rendering.

Fix

Add id=uuid4() to the local-branch constructors in both service modules, matching the Slurm branch. Worth also reconsidering whether the dry-run tests should exercise the real renderer — test_dry_run_renders_the_pinned_image (added in #493) does, which is how this surfaced.

Found while adding --image-ref (#492); unrelated to that change and pre-existing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions