Programming interfaces
Everything the tools and GUIs do is available from C++, C and Python. Reference man pages:
libfdp(3), fdp_c(3), fdptools(3).
C++: libfdp
#include <fdp/fdp.hpp> // CMake: find_package(fdp) ; target_link_libraries(app FDP::fdp)
fdp::Client client(fdp::Config::load()); // config file < .env < FDP_* environment
for (const auto &e : client.list("/amsc/public/treasure/aoj/data"))
std::cout << e.name << " " << e.size << "\n";
fdp::TransferOptions opt;
opt.recursive = true;
opt.parallel = 8;
fdp::TransferResult r = client.get({"/amsc/dune/scratch/me/run42"}, "./run42", opt);
std::cout << r.done() << " done, " << r.failed() << " failed\n";
| Header | Main types and functions |
|---|---|
fdp/config.hpp | Config: load(), set(key, value), get(key), to_yaml(), roles_for(project) |
fdp/client.hpp | Client: list, stat, exists, get, put, remove, mkdir, read, location, reconfigure, tokens() |
fdp/storage.hpp | Location (URL/path parsing), Entry, TransferOptions, TransferResult, Progress |
fdp/token.hpp | TokenManager: get, cached, for_path, choose, discover, role_for; TokenInfo, decode_token |
fdp/metacat.hpp | MetaCat REST client; amsc::generate_local, generate_remote, generate_remote_selection, validate, dataset_metadata |
fdp/tpc.hpp, fdp/globus.hpp | third_party_copy; Globus PKCE login and the AmSC data API |
fdp/diag.hpp, fdp/error.hpp | run_diagnostics; fdp::Error with ErrorCode (the CLI exit codes) |
C: fdp_c.h
A small, stable ABI for other languages (the Swift app uses it): opaque client handle, strings in and JSON
text out, every result freed with fdp_free. Functions return 0 or an ErrorCode and
set *error.
char *json = NULL, *err = NULL;
fdp_client *c = fdp_client_new("", "", &err);
if (fdp_list(c, "/amsc/public", 0, &json, &err) == 0) puts(json);
fdp_free(json); fdp_free(err); fdp_client_free(c);
Groups: client and configuration (fdp_client_new, fdp_config_get/set/yaml/save,
fdp_set_login_mode, fdp_set_output_callback); storage (fdp_list,
fdp_stat, fdp_mkdir, fdp_remove, fdp_get, fdp_put with
progress and cancel callbacks); tokens (fdp_role_for, fdp_token_for,
fdp_token_status, fdp_token_get, fdp_token_destroy, fdp_roles,
fdp_tokens); fdp_diagnostics; and fdp_metacat / fdp_globus, which take
an operation name and JSON arguments.
Python: fdptools
import fdptools
fdp = fdptools.FDP(interactive=False) # no browser logins from scripts
for e in fdp.ls("/amsc/public/treasure/aoj/data"):
print(e.name, e.size)
r = fdp.get("/amsc/public/treasure/aoj/data/RunG_batch0.h5", "/tmp/", parallel=4)
print(r.done, r.failed) # properties in Python
print(fdp.token_for("/amsc/dune/x", write=True).summary())
rec = fdp.metacat.find_by_path("/amsc/public/treasure/aoj/data/RunG_batch0.h5")
| Object | Methods |
|---|---|
FDP | ls, stat, exists, get, put, rm, mkdir, read_bytes, role_for, token_for, token, cached_token, tokens, diagnostics, third_party_copy, reconfigure |
FDP.metacat | login, logout, session, namespaces, datasets, dataset, dataset_files, file, query, find_by_path, create_namespace, create_dataset, declare_files, update_file_meta, generate, generate_selection, validate |
Config, Client, TokenManager | the C++ classes, for fine control |
Network calls release the GIL; progress callbacks can cancel a transfer by returning False. Errors
raise fdptools.FDPError; fdptools.error_code(e) gives the numeric code.
Routes of this website
The site is static: there is no server-side API. Each route is one file in a private S3 bucket, served over
HTTPS by CloudFront; unknown paths return 404.html with status 404.
| Route | Content |
|---|---|
/, /index.html | overview |
/tools.html | the fdp-* tools |
/tokens.html | token acquisition |
/gui.html | fdp-qt and FDP Browser |
/install.html | build, deploy and install |
/api.html | this page |
/about.html | project and dependencies |
/sitemap.html, /sitemap.xml, /robots.txt | site structure |
/assets/*, /images/* | stylesheet, icon, screenshots |