def analyze_spec(spec, analyzers=None, outdir=None, monitor=None, overwrite=False): """ Do an analysis for a spec, optionally adding monitoring. We also allow the user to specify a custom output directory. analyze_spec(spec, args.analyzers, args.outdir, monitor) Args: spec (spack.spec.Spec): spec object of installed package analyzers (list): list of analyzer (keys) to run monitor (spack.monitor.SpackMonitorClient): a monitor client overwrite (bool): overwrite result if already exists """ analyzers = analyzers or list(spack.analyzers.analyzer_types.keys()) # Load the build environment from the spec install directory, and send # the spec to the monitor if it's not known if monitor: monitor.load_build_environment(spec) monitor.new_configuration([spec]) for name in analyzers: # Instantiate the analyzer with the spec and outdir analyzer = spack.analyzers.get_analyzer(name)(spec, outdir) # Run the analyzer to get a json result - results are returned as # a dictionary with a key corresponding to the analyzer type, so # we can just update the data result = analyzer.run() # Send the result. We do them separately because: # 1. each analyzer might have differently organized output # 2. the size of a result can be large analyzer.save_result(result, overwrite)
def test_spack_monitor_build_env(mock_monitor_request, install_mockery_mutable_config): monitor = get_client(host="hostname") assert hasattr(monitor, "build_environment") for key in ["host_os", "platform", "host_target", "hostname", "spack_version", "kernel_version"]: assert key in monitor.build_environment spec = spack.spec.Spec("dttop") spec.concretize() # Loads the build environment from the spec install folder monitor.load_build_environment(spec)