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

Add function to query environment vars; class to represent SLURM info… #634

Merged
merged 1 commit into from
Jun 11, 2019

Conversation

timmah
Copy link
Contributor

@timmah timmah commented Jun 10, 2019

…rmation.

Background

  • We want to programmatically query SLURM state

Purpose of Pull Request

  • Add QueryEnv.hh header and unit test. QueryEnv provides a somewhat generic get_env_val, that calls the C getenv function and converts the result, if any, to the specified type. get_env_val() returns whether the key is defined in the environment, and the value found, if any. The SLURM_Task_Info class uses get_env_val to locate some SLURM-specific quantities.
  • Addresses Redmine Issue #1534

Description of changes

  • code added along with unit test

Status

src/c4/QueryEnv.hh Show resolved Hide resolved
@KineticTheory
Copy link
Collaborator

@timmah You can ignore appveyor failure on this PR. I updated the compiler version and there are new warnings that are unrelated to your changes.

@timmah timmah force-pushed the feat-add-slurm-vars branch 2 times, most recently from 73518fb to 59dca45 Compare June 10, 2019 22:09
…rmation.

Improve how get_env_val communicates whether a key is defined in the environment.

Include <tuple>.

Correct warnable syntactic shortcoming.

Fix directory mismatch in doxygen comments.

Fix doxygen usage.

Another doxygen fix.

Another clang-format.
Copy link
Collaborator

@KineticTheory KineticTheory left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for adding it.

template <typename T>
std::pair<bool, T> get_env_val(std::string const &key, T default_value = T{}) {
static_assert(std::is_default_constructible<T>::value,
"get_env_val only usable with default constructible types");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

@KineticTheory KineticTheory changed the title WIP: Add function to query environment vars; class to represent SLURM info… Add function to query environment vars; class to represent SLURM info… Jun 11, 2019
@KineticTheory KineticTheory added this to the Draco-7_2_0 milestone Jun 11, 2019
@KineticTheory KineticTheory merged commit 2b93557 into lanl:develop Jun 11, 2019
@KineticTheory KineticTheory mentioned this pull request Jun 17, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants