Package org.fairdatapipeline.api
Class Coderun
java.lang.Object
org.fairdatapipeline.api.Coderun
- All Implemented Interfaces:
AutoCloseable
Java implementation of the FAIR Data Pipeline API
Users should initialise this library using a try-with-resources block or ensure that .close() is explicitly closed when the required file handles have been accessed.
Usage example
try (var coderun = new Coderun(configPath, scriptPath, regToken)) {
ImmutableSamples samples = ImmutableSamples.builder().addSamples(1, 2, 3).rng(rng).build();
String dataProduct = "animal/dodo";
String component1 = "example-samples-dodo1";
Data_product_write dp = coderun.get_dp_for_write(dataProduct, "toml");
Object_component_write oc1 = dp.getComponent(component1);
oc1.raise_issue("something is terribly wrong with this component", 10);
oc1.writeSamples(samples);
}
Or, to write a CSV file, with issues on the DP and on the Code_repo:
try (var coderun = new Coderun(configPath, scriptPath, regToken)) {
String dataProduct = "human/health";
Data_product_write dp = coderun.get_dp_for_write(dataProduct, "toml");
Object_component_write oc1 = dp.getComponent();
CleanableFileChannel f = oc1.writeFileChannel();
my_analysis_csv_writer(f);
Issue i = coderun.raise_issue("something is terribly wrong with this component", 10);
i.add_components(oc1);
i.add_fileObjects(coderun.getCode_repo());
}
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor using only configFilePath - scriptPath is read from the config.Constructor using both configFilePath and ScriptPathConstructor specifying configPath, scriptPath, and registryToken. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Finalize and register the coderun.get_dp_for_read(String dataProduct_name) Obtain a data product for reading.get_dp_for_write(String dataProduct_name) Obtain a data product for writing.get_dp_for_write(String dataProduct_name, String extension) Obtain a data product for writing.Access the code repository in order to raise a code repository issue.Access the configuration file (config.yaml); in order to raise a Config issue.Access the Submission_script; in order to raise a Submission_script issue.raise_issue(String description, Integer severity) create an Issue that can be linked to a number ofobject componentsand/orfileObjects.
-
Constructor Details
-
Coderun
Constructor using only configFilePath - scriptPath is read from the config.- Parameters:
configFilePath- the Path to the config file, which must be located in the local data store CodeRun folder with timestamp name.
-
Coderun
Constructor using both configFilePath and ScriptPath- Parameters:
configFilePath- the Path to theconfig.yamlfilescriptPath- the Path to the script file - this may be null if the script path is given in the config file.both startup files are usually provided by fair run in the local data registry jobs/{timestamp} folder.
-
Coderun
Constructor specifying configPath, scriptPath, and registryToken.- Parameters:
configFilePath- the Path to theconfig.yamlfilescriptPath- the Path to the script file - this may be null if the script path is given in the config file.both startup files are usually provided by fair run in the local data registry jobs/{timestamp} folder.
registryToken- the authentication token of the local registry (or null if the token is to be read from the config or from ~/.fair/registry/token)
-
-
Method Details
-
getScript
Access the Submission_script; in order to raise a Submission_script issue.- Returns:
- the FileObject representing the Submission_script.
Usage:
coderun.getScript.raise_issue("this is a very bad script", 10);ORIssue i = coderun.raise_issue("Seriously bad stuff", 10); i.add_fileObjects(coderun.getScript(), coderun.getConfig());
-
getConfig
Access the configuration file (config.yaml); in order to raise a Config issue.- Returns:
- the FileObject representing the config file.
Usage:
coderun.getConfig.raise_issue("this is a very bad config file", 10);ORIssue i = coderun.raise_issue("Seriously bad stuff", 10); i.add_fileObjects(coderun.getScript(), coderun.getConfig());
-
getCode_repo
Access the code repository in order to raise a code repository issue.- Returns:
- the FileObject representing the code repository (which is given in the config file)
Usage:
coderun.getCode_repo.raise_issue("this contains very bad code", 10);ORIssue i = coderun.raise_issue("Seriously bad stuff", 10); i.add_fileObjects(coderun.getCode_repo(), coderun.getConfig());
-
get_dp_for_read
Obtain a data product for reading.- Parameters:
dataProduct_name- the name of the dataProduct to obtain.- Returns:
- the data product.
-
get_dp_for_write
Obtain a data product for writing.- Parameters:
dataProduct_name- the name of the dataProduct to obtain.extension- the file extension representing the file type we will write, e.g. csv or toml- Returns:
- the data product
-
get_dp_for_write
Obtain a data product for writing. (gets the extension from config)- Parameters:
dataProduct_name- the name of the dataProduct to obtain.- Returns:
- the data product
-
raise_issue
create an Issue that can be linked to a number ofobject componentsand/orfileObjects.- Parameters:
description- text description of the issueseverity- integer representing the severity of the issue, larger integer means more severe- Returns:
- the Issue
-
close
public void close()Finalize and register the coderun. (this gets called automatically when using Coderun in a try-with-resources block)- Specified by:
closein interfaceAutoCloseable
-