From f2b362b5b30e77fe6a2ccb2b2997ff000340d5f9 Mon Sep 17 00:00:00 2001 From: vsoch Date: Mon, 17 May 2021 17:33:15 -0600 Subject: adding support to tag a build This will be useful to run multiple build experiments and organize by name Signed-off-by: vsoch --- lib/spack/docs/monitoring.rst | 12 +++++++++++- lib/spack/spack/cmd/install.py | 1 + lib/spack/spack/monitor.py | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) (limited to 'lib') 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: @@ -84,6 +85,9 @@ def get_monitor_group(subparser): monitor_group.add_argument( '--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.") @@ -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: -- cgit v1.2.3-60-g2f50