flux-framework / dyad

DYAD: DYnamic and Asynchronous Data Streamliner
GNU Lesser General Public License v3.0
7 stars 5 forks source link

Creates a "core" library that implements all the shared functionality across APIs #14

Closed ilumsden closed 1 year ago

ilumsden commented 1 year ago

Previously, each API re-implements the main (or "core") functionality of DYAD, such as Flux KVS put/get operations and Flux RPC calls. This PR abstracts all this shared functionality into an underlying libdyad_core.so library with the following API:

// Store all the data needed to use DYAD
struct dyad_ctx;
typedef struct dyad_ctx dyad_ctx_t;

// Store information fetched from the Flux KVS
struct dyad_kvs_response;
typedef struct dyad_kvs_response dyad_kvs_response_t;

// Initialize DYAD and create a "dyad_ctx_t" object
int dyad_init(bool debug, bool check, bool shared_storage,
        unsigned int key_depth, unsigned int key_bins, 
        const char *kvs_namespace, const char* prod_managed_path,
        const char *cons_managed_path, bool intercept, dyad_ctx_t **ctx);

// Save (or "commit") file metadata into the Flux KVS
int dyad_commit(dyad_ctx_t *ctx, const char *fname);

// Fetch file metadata from the Flux KVS
int dyad_fetch(dyad_ctx_t *ctx, const char* fname, 
        dyad_kvs_response_t **resp);

// Initiate a Flux RPC call and retrieve (or "pull") the file from the producer
int dyad_pull(dyad_ctx_t *ctx, const char* fname,
        dyad_kvs_response_t *kvs_data);

// Free the dyadd_kvs_response_t objects created by "dyad_fetch"
int dyad_free_kvs_response(dyad_kvs_response_t *resp);

// Finalize DYAD and deallocate the "dyad_ctx_t" object
int dyad_finalize(dyad_ctx_t *ctx);

The library also provides two convenience functions for producing and consuming data:

// Wraps "dyad_commit"
int dyad_produce(dyad_ctx_t *ctx, const char *fname);
// Wraps "dyad_fetch" and "dyad_pull"
int dyad_consume(dyad_ctx_t *ctx, const char *fname);

Besides creating this library, this PR updates the C "sync" API and the C++ "stream" API to use the new "core" library.

Currently, to use the "core" library, the Automake files do the following:

This should mean that user code can use the API libraries without needing to manually link against libdyad_core.so. Alternatively, libdyad_core.la can be made a noinst target. However, this would prevent certain future decisions in the API libraries, such as making the C++ API a header-only library.

Finally, this PR makes some minor reorganization changes to the repo to make it easier for new developers or people outside the project to understand where code is. More specifically, it makes the following changes:

ilumsden commented 1 year ago

@JaeseungYeom I've fixed most of the comments you've made. The remaining things that are not yet addressed are:

I've resolved all the comments above that I have either fixed/addressed. The only ones that are still open are ones that either haven't been addressed or ones that I have responded to.

ilumsden commented 1 year ago

@JaeseungYeom this PR is almost done. The only comment you made above that I haven't yet resolved is the comment about renaming the error/return codes and the associated type. Otherwise, everything you've mentioned above has been resolved. I have also tested this PR using the ECP demo workflow, and it is working as intended.

At this point, I am going to open the PR as "ready for review". We can discuss the return code naming later this week. Then, all that will be left is any final reviewing you want to do.