diff options
author | vsoch <vsoch@users.noreply.github.com> | 2021-05-17 17:33:15 -0600 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2021-05-19 07:01:18 -0700 |
commit | f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9 (patch) | |
tree | 182a76e758a7bae7ded772ec234275aa8d5d36ad /lib | |
parent | 747e3cad1c7d32a5f3d3898a96c28b2c0960e650 (diff) | |
download | spack-f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9.tar.gz spack-f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9.tar.bz2 spack-f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9.tar.xz spack-f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9.zip |
adding support to tag a build
This will be useful to run multiple build experiments and organize by name
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/docs/monitoring.rst | 12 | ||||
-rw-r--r-- | lib/spack/spack/cmd/install.py | 1 | ||||
-rw-r--r-- | lib/spack/spack/monitor.py | 18 |
3 files changed, 26 insertions, 5 deletions
diff --git a/lib/spack/docs/monitoring.rst b/lib/spack/docs/monitoring.rst index 266f4dfe0a..b1d491c563 100644 --- a/lib/spack/docs/monitoring.rst +++ b/lib/spack/docs/monitoring.rst @@ -91,4 +91,14 @@ This could mean that if a request fails, you only have partial or no data added to your monitoring database. This setting will not be applied to the first request to check if the server is running, but to subsequent requests. If you don't have a monitor server running and you want to build, simply -don't provide the ``--monitor`` flag! +don't provide the ``--monitor`` flag! Finally, if you want to provide one or +more tags to your build, you can do: + +.. code-block:: console + + # Add one tag, "pizza" + $ spack install --monitor --monitor-tags pizza hdf5 + + # Add two tags, "pizza" and "pasta" + $ spack install --monitor --monitor-tags pizza,pasta hdf5 + diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 53e924cb9e..5b73c68de7 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -305,6 +305,7 @@ environment variables: host=args.monitor_host, prefix=args.monitor_prefix, disable_auth=args.monitor_disable_auth, + tags=args.monitor_tags, ) reporter = spack.report.collect_info( diff --git a/lib/spack/spack/monitor.py b/lib/spack/spack/monitor.py index 4c89b49b71..5d6246ebf1 100644 --- a/lib/spack/spack/monitor.py +++ b/lib/spack/spack/monitor.py @@ -31,7 +31,7 @@ from copy import deepcopy cli = None -def get_client(host, prefix="ms1", disable_auth=False, allow_fail=False): +def get_client(host, prefix="ms1", disable_auth=False, allow_fail=False, tags=None): """ Get a monitor client for a particular host and prefix. @@ -46,7 +46,8 @@ def get_client(host, prefix="ms1", disable_auth=False, allow_fail=False): the monitor use it. """ global cli - cli = SpackMonitorClient(host=host, prefix=prefix, allow_fail=allow_fail) + cli = SpackMonitorClient(host=host, prefix=prefix, allow_fail=allow_fail, + tags=tags) # If we don't disable auth, environment credentials are required if not disable_auth: @@ -85,6 +86,9 @@ def get_monitor_group(subparser): '--monitor-no-auth', action='store_true', dest='monitor_disable_auth', default=False, help="the monitoring server does not require auth.") monitor_group.add_argument( + '--monitor-tags', dest='monitor_tags', default=None, + help="One or more (comma separated) tags for a build.") + monitor_group.add_argument( '--monitor-keep-going', action='store_true', dest='monitor_keep_going', default=False, help="continue the build if a request to monitor fails.") monitor_group.add_argument( @@ -106,7 +110,7 @@ class SpackMonitorClient: to the client on init. """ - def __init__(self, host=None, prefix="ms1", allow_fail=False): + def __init__(self, host=None, prefix="ms1", allow_fail=False, tags=None): self.host = host or "http://127.0.0.1" self.baseurl = "%s/%s" % (self.host, prefix.strip("/")) self.token = os.environ.get("SPACKMON_TOKEN") @@ -115,6 +119,7 @@ class SpackMonitorClient: self.allow_fail = allow_fail self.spack_version = spack.main.get_version() self.capture_build_environment() + self.tags = tags # We keey lookup of build_id by full_hash self.build_ids = {} @@ -201,7 +206,8 @@ class SpackMonitorClient: # Always reset headers for new request. self.reset() - headers = headers or {} + # Preserve previously used auth token + headers = headers or self.headers # The calling function can provide a full or partial url if not endpoint.startswith("http"): @@ -367,6 +373,10 @@ class SpackMonitorClient: data = self.build_environment.copy() data['full_hash'] = full_hash + # If the build should be tagged, add it + if self.tags: + data['tags'] = self.tags + # If we allow the spec to not exist (meaning we create it) we need to # include the full spec.yaml here if not spec_exists: |