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

includes: name mangle ramble and include from spack normally #469

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

becker33
Copy link
Collaborator

@becker33 becker33 commented Dec 3, 2024

This PR allows us to import from Spack in the normal way instead of our crazy workaround.

The key is that we name mangle all of the ramble imports from spack.* to ramble_spack.* and llnl.* to ramble_llnl.*.

@github-actions github-actions bot added the configs New or modified system config label Dec 3, 2024
@becker33 becker33 force-pushed the becker/import-ramble-and-spack branch from 45485a0 to 2b25c2c Compare December 3, 2024 02:16
Copy link
Collaborator

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks reasonable but

  • There's a couple spots that could use documentation
  • The mangling of Ramble-as-a-lib vs. Ramble-as-a-driver is handled implicitly
  • I'd prefer some tweaks to the regexes (or at least some explanation in a docstring)

lib/benchpark/cmd/setup.py Outdated Show resolved Hide resolved
# If ramble is present but not yet name mangled, do that
ramble_spack_path = ramble_lib_path / "ramble_spack"
if not ramble_spack_path.exists():
self._mangle_ramble()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally we would conceptually distinguish the case where we clone ramble as a library vs. when we clone it to run it.

  • e.g. _install_ramble can be called from bootstrap() or .ramble() (via ramble_first_time_setup)
  • I'd recommend making the "library-ness" a property of the RuntimeResources object, and move this consideration to _install_ramble()
    • And maybe rename _install_ramble to reflect that it can update existing installations (i.e. so that this works for users that do a git pull of Benchpark with an already-established Ramble lib prefix

if not self.spack_location.exists():
self._install_spack()
def _mangle_ramble(self):
"""Name mangle ramble spack.* symbols to allow separate spack imports."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a bit of detail: mention we are replacing all instances of spack with ramble_spack, and all instances of llnl with [...].

Might be worth broadly outlining why this is expected to work: I don't think this name mangling would make all parts of Spack work, but I believe they make all the parts of Spack that Ramble uses work.

files = [
f
for f in fs.find(self.ramble_location, "*")
if os.stat(f).st_mode & stat.S_IWUSR and not os.path.isdir(f)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't own these files, we should probably fail, vs. silently doing nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment -- the main purpose here isn't to catch files we don't own, it's to catch files that aren't writable (like some things within the .git repo).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume nothing under .git should be modified: I recommend skipping it entirely (and explicitly).

if os.stat(f).st_mode & stat.S_IWUSR and not os.path.isdir(f)
]
file_filter = fs.FileFilter(*files)
# Don't replace if it's already replaced or if it's a field in an existing module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think trying to make these regexes idempotent will make them more confusing than they need to be: the existence of the ramble_spack directory can function as a sentinel (if you are worried about CTRL-C, I'd recommend a marker file); if we depend on that, I think we can stop considering _, which will simplify the regex.

Either way, I think this will work as long as:

# spack always does this
import spack.util.spack_yaml
# and never does this (which is allowed)
from spack.util import spack_yaml

But IMO it would be more straightforward to look for [\s]spack (i.e. spaces followed by spack)

I think including some examples of things you intend not to match would be useful (e.g. ...spack_yaml

@slabasan slabasan marked this pull request as draft December 12, 2024 04:38
@slabasan slabasan marked this pull request as ready for review December 18, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configs New or modified system config
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants