Skip to content

Commit

Permalink
Merge branch 'hotfix/1.26.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Jun 7, 2024
2 parents c28f641 + c2d6450 commit eeacdc8
Show file tree
Hide file tree
Showing 23 changed files with 487 additions and 92 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ ecbuild_add_option( FEATURE JEMALLOC
#### CUDA

ecbuild_add_option( FEATURE CUDA
DEFAULT OFF
CONDITION HAVE_EXPERIMENTAL
DESCRIPTION "CUDA GPU linear algebra operations"
REQUIRED_PACKAGES CUDA )
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,3 @@ make install
# 4. Check installation
$installdir/bin/eckit-version
```



2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.26.2
1.26.3
105 changes: 105 additions & 0 deletions src/eckit/config/Configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ eckit::Value Configuration::lookUp(const std::string& s, bool& found) const {
eckit::Value result = *root_;

for (size_t i = 0; i < path.size(); i++) {
if (!(result.isMap() || result.isOrderedMap())) {
found = false;
return result;
}
const std::string& key = path[i];
if (!result.contains(key)) {
found = false;
Expand Down Expand Up @@ -460,6 +464,107 @@ LocalConfiguration Configuration::getSubConfiguration(const std::string& name) c
return result;
}

bool Configuration::isIntegral(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && v.isNumber();
}

bool Configuration::isBoolean(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && v.isBool();
}

bool Configuration::isFloatingPoint(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && v.isDouble();
}

bool Configuration::isString(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && v.isString();
}

bool Configuration::isList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && v.isList();
}

bool Configuration::isSubConfiguration(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
return found && (v.isMap() || v.isOrderedMap());
}

bool Configuration::isIntegralList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
if (found && v.isList()) {
if (v.size() == 0) {
return true;
}
auto& firstElement = v[0];
return firstElement.isNumber();
}
return false;
}

bool Configuration::isBooleanList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
if (found && v.isList()) {
if (v.size() == 0) {
return true;
}
auto& firstElement = v[0];
return firstElement.isBool();
}
return false;
}

bool Configuration::isFloatingPointList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
if (found && v.isList()) {
if (v.size() == 0) {
return true;
}
auto& firstElement = v[0];
return firstElement.isDouble();
}
return false;
}

bool Configuration::isStringList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
if (found && v.isList()) {
if (v.size() == 0) {
return true;
}
auto& firstElement = v[0];
return firstElement.isString();
}
return false;
}

bool Configuration::isSubConfigurationList(const std::string& name) const {
bool found = false;
eckit::Value v = lookUp(name, found);
if (found && v.isList()) {
if (v.size() == 0) {
return true;
}
auto& firstElement = v[0];
return firstElement.isMap() || firstElement.isOrderedMap();
}
return false;
}

template <class T>
void Configuration::_getWithDefault(const std::string& name, T& value, const T& defaultVal) const {
if (!get(name, value)) {
Expand Down
80 changes: 80 additions & 0 deletions src/eckit/config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <cstdint>
#include <memory>
#include <type_traits>
#include "eckit/config/Parametrisation.h"


Expand Down Expand Up @@ -133,6 +134,70 @@ class Configuration : public Parametrisation {

virtual void hash(eckit::Hash&) const;

// -- Introspection methods

bool isSubConfiguration(const std::string& name) const;

bool isIntegral(const std::string& name) const;

bool isBoolean(const std::string& name) const;

bool isFloatingPoint(const std::string& name) const;

bool isString(const std::string& name) const;

bool isList(const std::string& name) const;

bool isSubConfigurationList(const std::string& name) const;

bool isIntegralList(const std::string& name) const;

bool isBooleanList(const std::string& name) const;

bool isFloatingPointList(const std::string& name) const;

bool isStringList(const std::string& name) const;

template <typename T>
bool isConvertible(const std::string& name) const {
using _T = std::decay_t<T>;
if constexpr(std::is_base_of_v<LocalConfiguration,_T>) {
return isSubConfiguration(name);
}
else if constexpr(std::is_same_v<_T,int> || std::is_same_v<_T,long> || std::is_same_v<_T,long long> || std::is_same_v<_T,std::size_t>) {
return isIntegral(name) || isBoolean(name);
}
else if constexpr(std::is_same_v<_T,float> || std::is_same_v<_T,double>) {
return isFloatingPoint(name) || isIntegral(name) || isBoolean(name);
}
else if constexpr(std::is_same_v<_T,std::string>) {
return isString(name);
}
else if constexpr(is_vector<_T>::value) {
using _V = std::decay_t<typename _T::value_type>;
if constexpr(std::is_base_of_v<LocalConfiguration,_V>) {
return isSubConfigurationList(name);
}
else if constexpr(std::is_same_v<_V,int> || std::is_same_v<_V,long> || std::is_same_v<_V,long long> || std::is_same_v<_V,std::size_t>) {
return isIntegralList(name) || isBooleanList(name);
}
else if constexpr(std::is_same_v<_V,float> || std::is_same_v<_V,double>) {
return isFloatingPointList(name) || isIntegralList(name) || isBooleanList(name);
}
else if constexpr(std::is_same_v<_V,std::string>) {
return isStringList(name);
}
}
else {
return false;
}
}

template <typename T>
bool isConvertible(const std::string& name, T&) const {
return isConvertible<T>(name);
}

protected: // methods
Configuration(const eckit::Value&, char separator = '.');

Expand Down Expand Up @@ -173,6 +238,21 @@ class Configuration : public Parametrisation {
p.print(s);
return s;
}

private:

// Helper structs for introspection of template T in isConvertible<T> method
template<class T>
struct is_vector {
using type = T ;
constexpr static bool value = false;
};

template<class T>
struct is_vector<std::vector<T>> {
using type = std::vector<T> ;
constexpr static bool value = true;
};
};

//----------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/eckit/filesystem/URI.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class URI {

// Contructors
URI();
URI(const std::string& uri);
explicit URI(const std::string& uri);
URI(const std::string& scheme, const PathName& path);
URI(const std::string& scheme, const URI& uri);
URI(const std::string& scheme, const std::string& hostname, int port);
Expand Down
6 changes: 4 additions & 2 deletions src/eckit/io/MultiHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ long MultiHandle::read1(char* buffer, long length) {
}

long n = (*current_)->read(buffer, length);
if (n <= 0) {
if (n < length) {
(*current_)->close();
current_++;
openCurrent();
return read1(buffer, length);
if (n <= 0) {
return read1(buffer, length);
}
}
return n;
}
Expand Down
24 changes: 20 additions & 4 deletions src/eckit/log/SysLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "eckit/runtime/Main.h"

#include "eckit/log/TimeStamp.h"
#include "eckit/net/IPAddress.h"

namespace eckit {

Expand All @@ -43,11 +44,26 @@ int SysLog::procid() const {
return ::getpid();
}


std::string SysLog::structuredData() const {
if (software_.empty() && swVersion_.empty() && enterpriseId_.empty()) {
return std::string(1, nilvalue());
}
// RFC 5424 section 6.3 (only origin)
std::ostringstream s;

/// @todo Implement the structured message meta-description as described in RFC5424 secion 6.3
s << nilvalue();
std::string ip = net::IPAddress::myIPAddress().asString();

s << "[origin ip=\"" << ip << "\"";
if (!enterpriseId_.empty()) {
s << " enterpriseId=\"" << enterpriseId_ << "\"";
}
if (!software_.empty()) {
s << " software=\"" << software_ << "\"";
if (!swVersion_.empty()) {
s << " swVersion=\"" << swVersion_ << "\"";
}
}
s << "]";

return s.str();
}
Expand All @@ -59,7 +75,7 @@ SysLog::operator std::string() const {
static char sep = ' ';

os // RFC 5424 section 6.2 (Header)
<< "<" << priotity() << ">" << version() << sep << timestamp() << sep << fqdn() << sep << appName() << sep
<< "<" << priority() << ">" << version() << sep << timestamp() << sep << fqdn() << sep << appName() << sep
<< procid() << sep << msgid()
<< sep
// RFC 5424 section 6.3
Expand Down
12 changes: 11 additions & 1 deletion src/eckit/log/SysLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SysLog {

SysLog(const std::string& msg, int msgid = 0, Facility f = SysLog::User, Severity s = SysLog::Info);

unsigned priotity() const { return facility_ * 8 + severity_; }
unsigned priority() const { return facility_ * 8 + severity_; }

unsigned version() const { return 1; }

Expand All @@ -99,6 +99,11 @@ class SysLog {
return s;
}

/// Optional fields for structured data (RFC 5424 section 6.3)
void software(const std::string& software) { software_ = software; }
void swVersion(const std::string& version) { swVersion_ = version; }
void enterpriseId(const std::string& id) { enterpriseId_ = id; }

private: // methods
void print(std::ostream& out) const;

Expand All @@ -112,6 +117,11 @@ class SysLog {
int msgid_;

std::string msg_;

// optional fields for structured data
std::string software_;
std::string swVersion_;
std::string enterpriseId_;
};

} // namespace eckit
Expand Down
8 changes: 8 additions & 0 deletions src/eckit/log/TimeStamp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/

#include <sstream>
#include <iomanip>
#include <cstdint>

#include "eckit/eckit.h"

Expand All @@ -27,6 +29,12 @@ TimeStamp::TimeStamp(time_t t, const std::string& format) :
time_(t), format_(format) {}

std::ostream& operator<<(std::ostream& s, const TimeStamp& x) {

if (x.format_ == "hex") {
s << std::setw(16) << std::setfill('0') << std::hex << static_cast<std::uint64_t>(x.time_);
return s;
}

char buf[80];
#if eckit_HAVE_GMTIME_R
struct tm t;
Expand Down
Loading

0 comments on commit eeacdc8

Please sign in to comment.