Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy EasyConfig instance in constructor of Bundle and Cargo easyblocks before making changes to it #3448

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

boegel
Copy link
Member

@boegel boegel commented Sep 15, 2024

required to make creating multiple EasyBlock instances from one EasyConfig instance works as intended + fix easybuilders/easybuild-easyconfigs#21393

@boegel boegel added the bug fix label Sep 15, 2024
@boegel boegel added this to the release after 4.9.3 milestone Sep 15, 2024
@boegel
Copy link
Member Author

boegel commented Sep 15, 2024

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Xvfb-21.1.9-GCCcore-13.2.0.eb
  • SUCCESS matplotlib-3.7.0-gfbf-2022b.eb
  • SUCCESS mfqe-0.5.0-GCC-12.3.0.eb
  • SUCCESS tokenizers-0.15.2-GCCcore-12.3.0.eb

Build succeeded for 4 out of 4 (4 easyconfigs in total)
node3105.skitty.os - Linux RHEL 8.8, x86_64, Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz, Python 3.6.8
See https://gist.github.com/boegel/beb1d58c012af6f896576c87ded12d61 for a full test report.

@branfosj branfosj merged commit 5357990 into easybuilders:develop Sep 15, 2024
41 checks passed
@boegel boegel deleted the bundle_cargo_copy_ec_instance branch September 15, 2024 15:48
@Micket
Copy link
Contributor

Micket commented Sep 15, 2024

hm, well, i'm not opposed, but we should make it clear or not if init method are expected to be idempotent or always copy. Seems very inconsistent that

x  = app_class(ec)
print(ec.is_this_data_modified_by_init)

will the input argument ec be modified or not? Now this depends on the easyblock inconsistently. I don't know if there is anywhere in easybuild normal framework that ever looks at the ec file after it has been passed to an app_class, but this would change this behavior. If framework never looks at the input ec parameter, then maybe none of the tests should do that either. If they all always just even avoids naming the ec object at all, i.e.

x = app_class(EasyConfig(file_content))
x.cfg <-- always do this

then tests would always be consistent with normal usage.

@boegel
Copy link
Member Author

boegel commented Sep 15, 2024

I'd say that EasyConfig instances passed to an EasyBlock constructor should never be modified "in place", since that an unwanted side effect that leads to confusion/bugs (see easybuilders/easybuild-easyconfigs#21393).

We're currently not enforcing this, but we probably should.

@Flamefire
Copy link
Contributor

I'd say that EasyConfig instances passed to an EasyBlock constructor should never be modified "in place"

That would mean we should likely do the copy in framework in the EasyBlock class because we have e.g. self.cfg.update and similar in many easyblocks. Not sure if that is always in the ctor or if we expect that the EasyConfig instance is unmodified after some other methods are called on the easyblock.

We could add a check in the easyconfig repo tests, that the EasyConfig instance is unmodified after the ctor because there we instantiate pretty much all easyblocks. We can also add a check in framework at the place where it instantiates the easyblock to fail if the ctor modifies it.

However I'm afraid that doing that check on scale would be expensive as it involves a deep copy and deep comparison. It would slow down the tests and/or runtime quite a bit I guess. But of course we'd need to measure that.

@boegel
Copy link
Member Author

boegel commented Sep 16, 2024

@boegel
Copy link
Member Author

boegel commented Sep 16, 2024

I'd say that EasyConfig instances passed to an EasyBlock constructor should never be modified "in place"

That would mean we should likely do the copy in framework in the EasyBlock class because we have e.g. self.cfg.update and similar in many easyblocks. Not sure if that is always in the ctor or if we expect that the EasyConfig instance is unmodified after some other methods are called on the easyblock.

We could add a check in the easyconfig repo tests, that the EasyConfig instance is unmodified after the ctor because there we instantiate pretty much all easyblocks. We can also add a check in framework at the place where it instantiates the easyblock to fail if the ctor modifies it.

However I'm afraid that doing that check on scale would be expensive as it involves a deep copy and deep comparison. It would slow down the tests and/or runtime quite a bit I guess. But of course we'd need to measure that.

Yeah, this likely needs some follow-up.

Always copying the EasyConfig instance makes sense, but there may be significant performance impact though, indeed.

@boegel boegel modified the milestones: release after 4.9.3, 4.9.4 Sep 19, 2024
@boegel boegel changed the title copy EasyConfig instance in constructor of Bundle and Cargo easyblocks before changes to it copy EasyConfig instance in constructor of Bundle and Cargo easyblocks before making changes to it Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test suite runs repeated __init__ which may incorrectly mutate self.cfg paremeter
4 participants