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