parent
48a1288891
commit
bdd8fd7e0d
6 changed files with 18 additions and 39 deletions
|
|
@ -60,8 +60,7 @@ public class UnifiedGenerateNumber {
|
|||
config.set("args", mapper.createArrayNode().add("will").add("generate").add(partitionRef));
|
||||
config.set("env", mapper.createObjectNode().put("PARTITION_REF", partitionRef));
|
||||
|
||||
var response = mapper.createObjectNode();
|
||||
response.set("configs", mapper.createArrayNode().add(config));
|
||||
var response = mapper.createArrayNode().add(config);
|
||||
|
||||
System.out.println(mapper.writeValueAsString(response));
|
||||
} catch (Exception e) {
|
||||
|
|
@ -90,11 +89,12 @@ public class UnifiedGenerateNumber {
|
|||
Random random = new Random(seed);
|
||||
int randomNumber = random.nextInt(100) + 1;
|
||||
|
||||
// Write to file
|
||||
File outputDir = new File(BASE_PATH);
|
||||
outputDir.mkdirs();
|
||||
|
||||
File outputFile = new File(outputDir, partitionRef + ".txt");
|
||||
// Write to file - partitionRef is the full path
|
||||
File outputFile = new File(partitionRef + ".txt");
|
||||
File outputDir = outputFile.getParentFile();
|
||||
if (outputDir != null) {
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
try (FileWriter writer = new FileWriter(outputFile)) {
|
||||
writer.write(String.valueOf(randomNumber));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ public class UnifiedSum {
|
|||
config.set("args", argsArray);
|
||||
config.set("env", mapper.createObjectNode().put("OUTPUT_REF", partitionRef));
|
||||
|
||||
var response = mapper.createObjectNode();
|
||||
response.set("configs", mapper.createArrayNode().add(config));
|
||||
var response = mapper.createArrayNode().add(config);
|
||||
|
||||
System.out.println(mapper.writeValueAsString(response));
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -2,29 +2,11 @@ load("@databuild//databuild:rules.bzl", "databuild_job")
|
|||
|
||||
databuild_job(
|
||||
name = "test_job",
|
||||
configure = ":test_job_configure",
|
||||
execute = ":test_job_execute",
|
||||
binary = ":test_job_binary",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
sh_binary(
|
||||
name = "test_job_configure",
|
||||
srcs = ["configure.sh"],
|
||||
)
|
||||
|
||||
sh_binary(
|
||||
name = "test_job_execute",
|
||||
srcs = ["execute.sh"],
|
||||
)
|
||||
|
||||
# New unified approach
|
||||
databuild_job(
|
||||
name = "unified_test_job",
|
||||
binary = ":unified_job_binary",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
sh_binary(
|
||||
name = "unified_job_binary",
|
||||
name = "test_job_binary",
|
||||
srcs = ["unified_job.sh"],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
test_job.cfg nice
|
||||
|
||||
test_job.cfg cool | jq -c ".configs[0]" | test_job.exec
|
||||
test_job.cfg cool | jq -c ".[0]" | test_job.exec
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ case "${1:-}" in
|
|||
"config")
|
||||
# Configuration mode - output job config JSON
|
||||
partition_ref="${2:-}"
|
||||
echo "{\"configs\":[{\"outputs\":[\"${partition_ref}\"],\"inputs\":[],\"args\":[\"will\", \"build\", \"${partition_ref}\"],\"env\":{\"foo\":\"bar\"}}]}"
|
||||
echo "[{\"outputs\":[\"${partition_ref}\"],\"inputs\":[],\"args\":[\"will\", \"build\", \"${partition_ref}\"],\"env\":{\"foo\":\"bar\"}}]"
|
||||
;;
|
||||
"exec")
|
||||
# Execution mode - run the job
|
||||
|
|
|
|||
|
|
@ -26,14 +26,12 @@ def handle_config(args):
|
|||
|
||||
partition_ref = args[0]
|
||||
|
||||
config = {
|
||||
"configs": [{
|
||||
"outputs": [partition_ref],
|
||||
"inputs": [],
|
||||
"args": ["Hello", "gorgeous", partition_ref],
|
||||
"env": {"PARTITION_REF": partition_ref}
|
||||
}]
|
||||
}
|
||||
config = [{
|
||||
"outputs": [partition_ref],
|
||||
"inputs": [],
|
||||
"args": ["Hello", "gorgeous", partition_ref],
|
||||
"env": {"PARTITION_REF": partition_ref}
|
||||
}]
|
||||
|
||||
print(json.dumps(config))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue