Skip to content

Re-initializing easyblocks modifies easyconfig input parameter #4289

@Micket

Description

@Micket

The easyconfig ec parameter gets passed as the first argument to EasyBlock's base init . This gets assigned as self.cfg = ec inside the easyblocks.
However, it's a few easyblocks (cargo, Bundle, and others) then modifies the self.cfg variable, modifying the referenced input argument ec .
This can break things in test suites and in the code as EasyBlock 's get initialized several times throughout the code.
Example: easybuilders/easybuild-easyconfigs#18027 failing at the time of writing this because check_sha256_checksum adds.
Workarounds have also been added in Cargo easyblock which prevents it from adding the crates to the source list repeatedly.

I think it also might be happening outside of just the check_sha256* CI stuff, and it just hasn't caused an issue.

  1. Maybe the base easyblock should get a copy self.cfg = deepcopy(ec) such that the original input argument isn't modified. But I don't know if there are any places where it's assumed that the ec should be modified by the constructor of the easyblocks.
  2. Add a parameter inside ec to detect if it's been initialized already, and add checks to skip that in Bundle. Quite fragile approach, but if this behavior is relied on, then this is still far better than the attempts to "restore" ec by trying to undo what the EasyBlock did (which is basically impossible, since it just guesses what the easyblock did and deletes everything it thinks was added).
  3. Try to fix CI not to repeat the initilization, presumably be preserving the easyblock instance somehow. Very ugly but perhaps the EasyConfig class could store a reference to it, i.e. lazily once init the easyblock?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions