2024-07-11 15:17:16 +02:00
|
|
|
include: "utils.smk"
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
DATE = datetime.datetime.now().strftime("%Y%m%d")
|
|
|
|
|
2024-07-16 13:59:44 +02:00
|
|
|
ARTIFACTS_FOLDER_NICKEL = "artifacts_nickel"
|
|
|
|
ARTIFACTS_FOLDER_JSON = "artifacts_json"
|
2024-07-11 15:17:16 +02:00
|
|
|
BLACKLIST_FOLDER = "blacklists"
|
|
|
|
BLACKLIST = "blacklist.csv"
|
2024-07-16 13:59:44 +02:00
|
|
|
EXTENSION = "json"
|
2024-07-11 15:17:16 +02:00
|
|
|
|
2024-07-16 13:59:44 +02:00
|
|
|
ARTIFACTS = get_artifacts_to_build(ARTIFACTS_FOLDER_NICKEL, BLACKLIST)
|
2024-07-11 15:17:16 +02:00
|
|
|
|
|
|
|
rule all:
|
|
|
|
input:
|
|
|
|
expand("{folder}/{artifact}/{date}.csv",\
|
|
|
|
folder=["logs", "pkgs", "status"],\
|
|
|
|
artifact=ARTIFACTS,\
|
|
|
|
date=DATE),
|
|
|
|
f"{BLACKLIST_FOLDER}/{DATE}.csv"
|
|
|
|
|
2024-07-16 13:59:44 +02:00
|
|
|
rule check_artifact:
|
|
|
|
input:
|
|
|
|
"flake.nix",
|
|
|
|
"flake.lock",
|
|
|
|
contract="workflow/nickel/artifact_contract.ncl",
|
|
|
|
artifact=f"{ARTIFACTS_FOLDER_NICKEL}/{{artifact}}.ncl"
|
|
|
|
output:
|
|
|
|
f"{ARTIFACTS_FOLDER_JSON}/{{artifact}}.json"
|
|
|
|
shell:
|
|
|
|
"""
|
|
|
|
nickel export --format json --output {output} <<< 'let {{Artifact, ..}} = import "{input.contract}" in ((import "{input.artifact}") | Artifact)'
|
|
|
|
"""
|
|
|
|
|
2024-07-11 15:17:16 +02:00
|
|
|
rule run_ecg:
|
|
|
|
input:
|
|
|
|
"flake.nix",
|
|
|
|
"flake.lock",
|
|
|
|
ecg="ecg.py",
|
2024-07-16 13:59:44 +02:00
|
|
|
artifact=f"{ARTIFACTS_FOLDER_JSON}/{{artifact}}.{EXTENSION}"
|
2024-07-11 15:17:16 +02:00
|
|
|
output:
|
|
|
|
log = "logs/{artifact}/{date}.csv",
|
|
|
|
pkg = "pkgs/{artifact}/{date}.csv",
|
|
|
|
status = "status/{artifact}/{date}.csv",
|
|
|
|
shell:
|
2024-07-16 13:59:44 +02:00
|
|
|
f"python3 {{input.ecg}} --log {{output.log}} --pkg {{output.pkg}} --status {{output.pkg}} {ARTIFACTS_FOLDER_JSON}/{{wildcards.artifact}}.{EXTENSION}"
|
2024-07-11 15:17:16 +02:00
|
|
|
|
|
|
|
rule update_blacklist:
|
|
|
|
input:
|
|
|
|
BLACKLIST,
|
|
|
|
status=expand("status/{artifact}/{{date}}.csv",\
|
|
|
|
artifact=ARTIFACTS)
|
|
|
|
output:
|
|
|
|
f"{BLACKLIST_FOLDER}/{{date}}.csv"
|
|
|
|
shell:
|
|
|
|
f"cat {{input}} > {{output}} && ln -s {{output}} {BLACKLIST}"
|