scrc-cpp-api

C++ Implementation of the SCRC FAIR Data Pipeline API

https://github.com/kzscisoft/scrc-cpp-api

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.6%) to scientific vocabulary
Last synced: 9 months ago · JSON representation ·

Repository

C++ Implementation of the SCRC FAIR Data Pipeline API

Basic Info
  • Host: GitHub
  • Owner: kzscisoft
  • License: bsd-3-clause
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 369 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 5 years ago · Last pushed almost 5 years ago
Metadata Files
Readme Changelog License Citation

README.md

FAIR Data Pipeline C++ API

NOTE: Currently this API implementation consists of components, assembly of these will depend on the final structure of the API itself.

Contents

Outline

The main class the user will interact with is DataPipeline which has only the required methods such as read_estimate 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.

Development has been made mainly to this internal class, the idea being that the top layer API will be constructed once the schema/workflow for FAIR Data Pipeline is finalised.

API Backend Components

The included unit tests show the API in action testing various methods for DataPipelineImpl_, LocalFileSystem and the extra utility methods required.

API

The core of the framework is the API class which sends and receives information to the RestAPI via CURL. It has no specific knowledge about the pipeline itself.

```c++

include "fdp/registry/api.hxx"

include "json/json.h"

include

include

using namespace FDP;

void run_api() { API* api = new API("https://data.scrc.uk/api/");

Json::Value data;
data["website"] = "www.nosuchsite.uk";
data["name"] = "test_data";
data["abbreviation"] = "nss";

const std::string api_token = "APITOKEN";

api->request("object/1234");
api->post("source", data, api_token);

} ```

LocalFileSystem

This largely handles the translation of statements in the configuration file into the retrieval of or submission of objects in the registry. It includes most of the HDF5 reading methods.

Reading an Estimate

```c++

include "fdp/registry/file_system.hxx"

include

using namespace FDP;

void readparamdemo() { const std::filesystem::path tomlfile = "/path/to/estimate/0.1.0.toml"; const double value = readpointestimatefromtoml(tomlfile); } ```

Reading an Array

```c++

include "fdp/registry/file_system.hxx"

include "fdp/objects/data.hxx"

include

using namespace FDP;

void readarraydemo() { const std::filesystem::path arrayfile = "path/to/array/0.20210427.0.h5"; const std::filesystem::path component = "testarray"; const ArrayObject* readarray(arrayfile, component); } ```

Reading a Data Table Column

```c++

include "fdp/registry/file_system.hxx"

include "fdp/objects/data.hxx"

include

include

using namespace FDP;

void readtablecoldemo() { const std::filesystem::path arrayfile = "path/to/array/0.20210427.0.h5"; const std::filesystem::path component = "testtable"; const std::string column = "col1"; const DataTableColumn* readtablecolumn(array_file, component, column); } ```

Reading a Distribution

```c++

include "fdp/registry/file_system.hxx"

include "fdp/objects/distributions.hxx"

include

include

using namespace FDP;

void readdistributiondemo() { const std::filesystem::path tomlfile = "/path/to/distribution/0.1.0.toml"; const Distribution* dis = readdistributionfromtoml(toml_file);

std::random_device rd;
std::mt19937* gen = new std::mt19937(rd());
const double random_val = dis->generate(gen);

} ```

Creating an Estimate

```c++

include "fdp/registry/file_system.hxx"

include "fdp/utilities/semver.hxx"

include

include

using namespace FDP;

void createparamdemo() { const std::filesystem::path configfile = "path/to/config.yaml"; LocalFileSystem* filesystem = new LocalFileSystem(config_file);

const version v1(0, 2, 0);
const double value = 7;
const std::string label = "my_params/param_a";

create_estimate(value, label, v1, file_system);

} ```

Creating a Distribution

```c++

include "fdp/registry/file_system.hxx"

include "fdp/utilities/semver.hxx"

include

include

using namespace FDP;

void createdisdemo() { const std::filesystem::path configfile = "path/to/config.yaml"; LocalFileSystem* filesystem = new LocalFileSystem(config_file);

const version v1(0, 2, 0);
const std::string label = "my_distributions/dis_a";

const double mu = 5.2;
const double sigma = 1.2;

Normal* dis = new Normal(mu, sigma);

create_distribution(dis, label, v1, file_system);

} ```

Creating an Array

```c++

include "fdp/registry/file_system.hxx"

include "fdp/objects/data.hxx"

include

include

using namespace FDP;

void createarraydemo() { const std::filesystem::path configfile = "path/to/config.yaml"; LocalFileSystem* filesystem = new LocalFileSystem(config_file);

const std::filesystem::path data_product = "test_data/test_arrays";
const std::filesystem::path component = "demo_1";

const ArrayObject<float>* arr = new ArrayObject<float>(
    {"dimension_1", "dimension_2"},             // Dimension titles
    {{"a1", "a2", "a3"}, {"b1", "b2", "b3"}},   // Dimension names
    {3, 3},                                     // Dimension sizes
    {1., 2., 3., 4., 5., 6., 7., 8., 9.}
);

create_array(arr, data_product, component, file_system);

} ```

Installation

You can build and test the library using CMake, this implementation requires C++17 or later as it makes use of the std::filesystem library. All dependencies are externally fetched however it is recommended that you install the following in advance:

compile the library and tests by running:

$ cmake -Bbuild -DFDPAPI_BUILD_TESTS=ON $ cmake --build build

Unit Tests

The unit tests connect to the FDP remote registry API, and so will not work if this service is no longer available.

Before running the tests you will need to download the test data sets by running:

$ bash test/test_setup.sh you can then launch the GTest binary created during compilation: $ ./build/test/fdpapi-tests

Owner

  • Name: Kristian Zarębski
  • Login: kzscisoft
  • Kind: user
  • Company: United Kingdom Atomic Energy Authority

Citation (CITATION.cff)

# YAML 1.2
---
abstract: "C++ Implementation of the API for the FAIR Data Pipeline."
authors: 
  -
    affiliation: UKAEA
    family-names: Zarebski
    given-names: Kristian
    orcid: "https://orcid.org/0000-0002-6773-1049"
  -
    affiliation: UKAEA
    family-names: Middleweek
    given-names: Tyler
cff-version: "1.1.0"
keywords: 
license: "BSD-3-Clause"
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/FAIRDataPipeline/FDP-Cpp-API"
title: "FAIR Data Pipeline C++ API"

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels