-
Notifications
You must be signed in to change notification settings - Fork 117
[feat] Improve Sarus backend #1737
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
Changes from all commits
3c5591a
feb003f
e17d4ed
346400b
ff868ad
d7bb025
6c71a15
9a3c0ab
93f19c9
ac6fd8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |||||
| import reframe.core.fields as fields | ||||||
| import reframe.utility.typecheck as typ | ||||||
| from reframe.core.exceptions import ContainerError | ||||||
|
|
||||||
| import tempfile | ||||||
|
|
||||||
| class ContainerPlatform(abc.ABC): | ||||||
| '''The abstract base class of any container platform.''' | ||||||
|
|
@@ -88,9 +88,6 @@ def validate(self): | |||||
| if self.image is None: | ||||||
| raise ContainerError('no image specified') | ||||||
|
|
||||||
| if not self.commands: | ||||||
| raise ContainerError('no commands specified') | ||||||
|
|
||||||
|
|
||||||
| class Docker(ContainerPlatform): | ||||||
| '''Container platform backend for running containers with `Docker | ||||||
|
|
@@ -119,32 +116,57 @@ class Sarus(ContainerPlatform): | |||||
| #: :default: :class:`False` | ||||||
| with_mpi = fields.TypedField(bool) | ||||||
|
|
||||||
| #: Using metahub to fetch instance specific images | ||||||
| #: | ||||||
| #: :type: boolean | ||||||
| #: :default: :class:`False` | ||||||
| with_metahub = fields.TypedField(bool) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about replacing this with
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually the registry is part of the string that is the image name. But in a greater scheme of things the question becomes how do you deal with container images compared to binaries installed on a system? |
||||||
| #: Skipping pull alltogether to speed up runs | ||||||
| #: | ||||||
| #: :type: boolean | ||||||
| #: :default: :class:`False` | ||||||
| skip_pull = fields.TypedField(bool) | ||||||
|
|
||||||
| def __init__(self): | ||||||
| super().__init__() | ||||||
| self.with_mpi = False | ||||||
| self._command = 'sarus' | ||||||
| self.with_metahub = False | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed since you can specify some hooks to be run before each step of the test pipeline. |
||||||
| self.skip_pull = False | ||||||
|
|
||||||
| def emit_prepare_commands(self): | ||||||
| # The format that Sarus uses to call the images is | ||||||
| # <reposerver>/<user>/<image>:<tag>. If an image was loaded | ||||||
| # locally from a tar file, the <reposerver> is 'load'. | ||||||
| if self.image.startswith('load/'): | ||||||
| if self.image.startswith('load/') or self.skip_pull: | ||||||
| return [] | ||||||
|
|
||||||
| return [self._command + ' pull %s' % self.image] | ||||||
| # Using | ||||||
| if self.with_metahub: | ||||||
| tmpdir = tempfile.mkdtemp() | ||||||
| return [ | ||||||
| 'docker pull -q mh.qnib.org/'+self.image, | ||||||
| 'docker save -o '+tmpdir+'/image.tar mh.qnib.org/'+self.image, | ||||||
|
Comment on lines
+147
to
+148
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, you should put this logic on the test as a prerun step. When sarus can pull directly, you just remove the workaround from the particular test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, you can use skopeo to copy the image directly as a docker-archive and load it with sarus |
||||||
| self._command + ' load ${TMP_DIR}/gromacs.tar mh.qnib.org/'+self.image, | ||||||
| 'rm -rf '+tmpdir | ||||||
| ] | ||||||
| else: | ||||||
| return [self._command + ' pull %s' % self.image] | ||||||
|
|
||||||
| def launch_command(self): | ||||||
| super().launch_command() | ||||||
| run_opts = ['--mount=type=bind,source="%s",destination="%s"' % | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| mp for mp in self.mount_points] | ||||||
| run_opts.append('--workdir='+self.workdir) | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaner then just changing the dir with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if self.with_mpi: | ||||||
| run_opts.append('--mpi') | ||||||
|
|
||||||
| run_opts += self.options | ||||||
| run_cmd = self._command + ' run %s %s bash -c ' % (' '.join(run_opts), | ||||||
| run_cmd = self._command + ' run %s %s' % (' '.join(run_opts), | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, the entrypoint you specify here (
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| self.image) | ||||||
| return run_cmd + "'" + '; '.join( | ||||||
| ['cd ' + self.workdir] + self.commands) + "'" | ||||||
| if self.commands: | ||||||
| return run_cmd + " '" + '; '.join(self.commands) + "'" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are not going to use |
||||||
| else: | ||||||
| return run_cmd | ||||||
|
|
||||||
|
|
||||||
| class Shifter(Sarus): | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creator of an images should know best how to execute the command. E.g. for Spack the
ENTRYPOINTneeds to be honored.I'd like to argue that a container should also include the execution script.