Skip to content

Commit 1bcc48a

Browse files
authored
Merge pull request #23 from FAIRDataPipeline/dev
Dev
2 parents fa62b6c + 9175149 commit 1bcc48a

35 files changed

+886
-322
lines changed

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ INCLUDE( external/jsoncpp.cmake )
6161
INCLUDE( external/digestpp.cmake )
6262
INCLUDE( external/curl.cmake )
6363
INCLUDE( external/yaml_cpp.cmake )
64-
INCLUDE( external/spdlog.cmake )
6564
INCLUDE( external/toml11.cmake )
6665
INCLUDE( external/ghc.cmake )
6766

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ $ cmake --build build --config=Release
3333
## Outline
3434
The main class the user will interact with is `DataPipeline` which has only the required methods such as `link_read` etc. This class has a member which is a pointer to an underlying `DataPipelineImpl_` class which performs the various procedures required to handle the data. A logger has been used to give as much feedback to the user as possible, the verbosity being handled by a log level argument.
3535

36+
### Logging
37+
The environment variable `FDP_LOG_LEVEL=[TRACE:DEBUG:INFO:WARN:ERROR:CRITICAL:OFF]` can be set to specify the logging output level.
3638

3739
## Unit Tests
3840
The unit tests use the local registry, this needs to be running prior to running the tests see: [the CLI documentation](https://github.com/FAIRDataPipeline/FAIR-CLI#registry)

external/digestpp.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SET( DIGESTCPP_COMMIT "34ff2eeae397ed744d972d86b5a20f603b029fbd" )
77
# So tell the compiler to exclude min and max macros in windows
88
IF(WIN32)
99
add_definitions(-DNOMINMAX)
10+
add_definitions(-DNOGDI)
1011
ENDIF()
1112

1213
MESSAGE( STATUS "[DigestCPP]" )

external/jsoncpp.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ MESSAGE( STATUS "[JsonCPP]" )
44
MESSAGE( STATUS "\tJsonCpp Will be installed." )
55
MESSAGE( STATUS "\tURL: ${JSONCPP_URL}" )
66

7+
SET (JSONCPP_WITH_TESTS OFF CACHE INTERNAL "Don't Build cpp tests")
8+
79
include(FetchContent)
810
FetchContent_Declare(
911
JsonCpp

external/spdlog.cmake

-13
This file was deleted.

include/fdp/exceptions.hxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stdexcept>
55
#include <string>
66

7-
namespace FDP {
7+
namespace FairDataPipeline {
88
class config_parsing_error : public std::runtime_error {
99
public:
1010
config_parsing_error(const std::string& message)
@@ -37,6 +37,6 @@ public:
3737
write_error(const std::string& message) : std::runtime_error(message) {}
3838
};
3939

40-
}; // namespace FDP
40+
}; // namespace FairDataPipeline
4141

4242
#endif

include/fdp/fdp.hxx

+20-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#ifndef __FDP__
22
#define __FDP__
33

4-
#include "spdlog/spdlog.h"
5-
#include <ghc/filesystem.hpp>
4+
#include "utilities/logging.hxx"
65

7-
//#include "fdp/registry/datapipeline.hxx"
6+
#include <ghc/filesystem.hpp>
87

9-
namespace FDP {
8+
namespace FairDataPipeline {
109
/**
1110
* @brief DataPipeline Class:
1211
* A PIMPL Class for interacting the the FAIR Data Pipeline
@@ -15,31 +14,29 @@ namespace FDP {
1514
class DataPipeline {
1615

1716
public:
17+
typedef std::shared_ptr< DataPipeline > sptr;
1818
/**
1919
* @brief Construct a new Data Pipeline (PIMPL)
2020
*
2121
* @param config_file_path
2222
* @param script_file_path
2323
* @param token
24-
* @param log_level
2524
*/
26-
explicit DataPipeline(
25+
static sptr construct(
2726
const std::string &config_file_path,
2827
const std::string &script_file_path,
29-
std::string token = "",
30-
spdlog::level::level_enum log_level = spdlog::level::info);
28+
std::string token = "" );
29+
3130

3231
/**
3332
* @brief Destroy the Data Pipeline object
3433
*
3534
*/
3635
~DataPipeline();
3736

38-
DataPipeline(DataPipeline &&rhs) noexcept;
39-
DataPipeline &operator=(DataPipeline &&rhs) noexcept;
37+
//DataPipeline(DataPipeline &&rhs) noexcept;
38+
//DataPipeline &operator=(DataPipeline &&rhs) noexcept;
4039

41-
DataPipeline(const DataPipeline &rhs);
42-
DataPipeline &operator=(const DataPipeline &rhs);
4340

4441
/**
4542
* @brief Return a path to a given data product
@@ -68,10 +65,19 @@ namespace FDP {
6865
void finalise();
6966

7067
private:
68+
explicit DataPipeline(
69+
const std::string &config_file_path,
70+
const std::string &script_file_path,
71+
std::string token = ""
72+
);
73+
74+
DataPipeline(const DataPipeline &rhs) = delete;
75+
76+
DataPipeline &operator=(const DataPipeline &rhs) = delete;
77+
7178
class impl;
7279

7380
std::shared_ptr< DataPipeline::impl > pimpl_;
7481
};
75-
}; // namespace FDP
76-
82+
}; // namespace FairDataPipeline
7783
#endif

include/fdp/objects/api_object.hxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "fdp/utilities/logging.hxx"
99

10-
namespace FDP {
10+
namespace FairDataPipeline {
1111
/**
1212
* @brief Class for API objects
1313
*
@@ -49,7 +49,7 @@ namespace FDP {
4949
* @return int object id e.g. if the uri is http://127.0.0.1/object/1
5050
* the object id will be 1
5151
*/
52-
int get_id();
52+
int get_id() const ;
5353
/**
5454
* @brief Get the object type from the uri
5555
*
@@ -58,7 +58,7 @@ namespace FDP {
5858
*/
5959
static int get_id_from_string(std::string url);
6060

61-
std::string get_type();
61+
std::string get_type() const ;
6262
/**
6363
* @brief Get the object uri
6464
*

include/fdp/objects/config.hxx

+12-8
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@
2525
#include "fdp/objects/api_object.hxx"
2626
#include "fdp/objects/io_object.hxx"
2727

28-
namespace FDP {
28+
namespace FairDataPipeline {
2929
/**
3030
* @brief class for interacting with confifurations
3131
*
3232
*/
3333
class Config {
34+
public:
35+
typedef std::shared_ptr< Config > sptr;
36+
37+
typedef std::map< std::string, IOObject > map_type;
38+
3439
private:
3540
const ghc::filesystem::path config_file_path_;
3641
const ghc::filesystem::path config_dir_;
@@ -59,11 +64,11 @@ namespace FDP {
5964

6065
ApiObject::sptr code_run_;
6166

62-
std::map<std::string, IOObject> writes_;
63-
std::map<std::string, IOObject> reads_;
67+
map_type writes_;
68+
map_type reads_;
6469

65-
std::map<std::string, IOObject> outputs_;
66-
std::map<std::string, IOObject> inputs_;
70+
map_type outputs_;
71+
map_type inputs_;
6772

6873
RESTAPI rest_api_location_ = RESTAPI::LOCAL;
6974

@@ -87,7 +92,6 @@ namespace FDP {
8792

8893

8994
public:
90-
typedef std::shared_ptr< Config > sptr;
9195

9296
static Config::sptr construct(const ghc::filesystem::path &config_file_path,
9397
const ghc::filesystem::path &script_file_path,
@@ -225,15 +229,15 @@ namespace FDP {
225229
* @param data_product
226230
* @return ghc::filesystem::path
227231
*/
228-
ghc::filesystem::path link_write(std::string &data_product);
232+
ghc::filesystem::path link_write( const std::string &data_product);
229233

230234
/**
231235
* @brief Return the filepath to a given data product
232236
*
233237
* @param data_product
234238
* @return ghc::filesystem::path
235239
*/
236-
ghc::filesystem::path link_read(std::string &data_product);
240+
ghc::filesystem::path link_read(const std::string& data_product);
237241

238242
/**
239243
* @brief Finalise the pipeline

include/fdp/objects/io_object.hxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "fdp/utilities/logging.hxx"
99
#include "fdp/objects/api_object.hxx"
1010

11-
namespace FDP {
11+
namespace FairDataPipeline {
1212
/**
1313
* @brief Class for API objects
1414
*
@@ -123,7 +123,7 @@ namespace FDP {
123123
*
124124
* @return const std::string&
125125
*/
126-
const std::string& get_use_namespace() {return use_namespace_;}
126+
const std::string& get_use_namespace() const {return use_namespace_;}
127127

128128
/**
129129
* @brief Get the path of the data product
@@ -144,7 +144,7 @@ namespace FDP {
144144
*
145145
* @return std::string
146146
*/
147-
const std::string& get_component_description() {return component_description_;}
147+
const std::string& get_component_description() const {return component_description_;}
148148

149149
/**
150150
* @brief Check whether the data product is public

include/fdp/objects/metadata.hxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! **************************************************************************
2-
* @file fdp/objects/metadata.hxx
2+
* @file FairDataPipeline/objects/metadata.hxx
33
* @author K. Zarebski (UKAEA)
44
* @date 2021-05-05
55
* @brief File containing methods for handling of metadata
@@ -29,7 +29,7 @@
2929
#include <unistd.h>
3030
#endif
3131

32-
namespace FDP {
32+
namespace FairDataPipeline {
3333
/*! **************************************************************************
3434
* @brief calculates a hash from a given input file via SHA1
3535
*
@@ -94,6 +94,6 @@ bool file_exists( const std::string &Filename );
9494
*/
9595
std::string read_token(const ghc::filesystem::path &token_path);
9696

97-
}; // namespace FDP
97+
}; // namespace FairDataPipeline
9898

9999
#endif

include/fdp/registry/api.hxx

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*! **************************************************************************
2-
* @file fdp/registry/api.hxx
2+
* @file FairDataPipeline/registry/api.hxx
33
* @author K. Zarebski (UKAEA)
44
* @date 2021-05-05
55
* @brief File containing classes and methods for connecting to the RestAPI
66
*
7-
* The classes and methods within this file are used to access the FDP
7+
* The classes and methods within this file are used to access the FairDataPipeline
88
* Data Pipeline RestAPI, they handle sending of requests and retrieval of
99
* data as JSON strings
1010
****************************************************************************/
@@ -27,7 +27,7 @@
2727
#include "fdp/utilities/json.hxx"
2828
#include "fdp/utilities/logging.hxx"
2929

30-
namespace FDP {
30+
namespace FairDataPipeline {
3131
/*! **************************************************************************
3232
* @enum RESTAPI
3333
* @brief selection of either local or remote pipeline running
@@ -39,6 +39,7 @@ enum class RESTAPI {
3939
LOCAL /*!< Run from local registry */
4040
};
4141

42+
#if 0
4243
/*! **************************************************************************
4344
* @brief function for writing to file from a CURL call
4445
* @author K. Zarebski (UKAEA)
@@ -50,6 +51,7 @@ enum class RESTAPI {
5051
* @return size_t
5152
****************************************************************************/
5253
size_t write_func_(void *ptr, size_t size, size_t nmemb, std::string *data);
54+
#endif
5355

5456
/*! **************************************************************************
5557
* @class API
@@ -70,8 +72,8 @@ public:
7072
*
7173
* @param url_root the root of the query address, e.g. localhost:8000/api
7274
***************************************************************************/
73-
API(std::string url_root)
74-
: url_root_(API::append_with_forward_slash(url_root)) {}
75+
static sptr construct( const std::string& url_root );
76+
7577

7678
/**
7779
* @brief sends the given 'packet' of information to the RestAPI
@@ -164,6 +166,9 @@ public:
164166
static std::string remove_leading_forward_slash(std::string str);
165167

166168
private:
169+
API( const std::string& url_root)
170+
: url_root_(API::append_with_forward_slash(url_root)) {}
171+
167172
std::string url_root_;
168173
CURL *setup_json_session_(std::string &addr_path, std::string *response,
169174
long &http_code, std::string token = "");
@@ -181,8 +186,8 @@ private:
181186
ghc::filesystem::path out_path);
182187
};
183188

184-
std::string url_encode(std::string url);
189+
std::string url_encode(const std::string& url);
185190

186-
}; // namespace FDP
191+
}; // namespace FairDataPipeline
187192

188193
#endif

include/fdp/registry/data_io.hxx

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! **************************************************************************
2-
* @file fdp/registry/config.hxx
2+
* @file FairDataPipeline/registry/config.hxx
33
* @author K. Zarebski (UKAEA)
44
* @date 2021-05-06
55
* @brief File containing classes for interacting with the local file system
@@ -27,7 +27,7 @@
2727
#include "fdp/utilities/logging.hxx"
2828
#include "fdp/utilities/semver.hxx"
2929

30-
namespace FDP {
30+
namespace FairDataPipeline {
3131

3232
/*! ***************************************************************************
3333
* @brief read the value of a point estimate from a given TOML file
@@ -87,8 +87,10 @@ ghc::filesystem::path create_estimate(T &value,
8787

8888
toml_out_.close();
8989

90-
APILogger->debug("FileSystem:CreateEstimate: Wrote point estimate to '{0}'",
91-
output_filename_.string());
90+
91+
auto the_logger = logger::get_logger();
92+
the_logger->debug()
93+
<< "FileSystem:CreateEstimate: Wrote point estimate to '" << output_filename_.string() << "'";
9294

9395
return output_filename_;
9496
}
@@ -101,6 +103,6 @@ ghc::filesystem::path create_estimate(T &value,
101103
*/
102104
std::string get_first_key_(const toml::value data_table);
103105

104-
}; // namespace FDP
106+
}; // namespace FairDataPipeline
105107

106-
#endif
108+
#endif

0 commit comments

Comments
 (0)