Spaces:
Sleeping
Sleeping
import os | |
import json | |
from types import SimpleNamespace | |
from kaggle_service import KernelRerunService, NbJob | |
import argparse | |
from logger import sheet_logger | |
def main(args): | |
if not os.path.exists(args.config): | |
print(f"Config folder not found: {os.path.abspath(args.config)}") | |
exit(1) | |
configs = [] | |
if os.path.isdir(args.config): | |
files = os.listdir(args.config) | |
for file in files: | |
with open(os.path.join(args.config, file), "r") as f: | |
obj = json.loads(f.read()) | |
configs.append(obj) | |
print(obj) | |
elif os.path.isfile(args.config): | |
with open(args.config, "r") as f: | |
obj = json.loads(f.read()) | |
configs.append(obj) | |
print(obj) | |
service = KernelRerunService() | |
for config in configs: | |
service.add_job(NbJob.from_dict(config)) | |
if args.option == "run": | |
service.run_all() | |
elif args.option == "validate": | |
service.validate_all() | |
elif args.option == "status": | |
service.status_all() | |
else: | |
print(f"Invalid option: {args.option}") | |
if __name__ == "__main__": | |
# parser = argparse.ArgumentParser() | |
# parser.add_argument("option", type=str, default="run", choices=["run", "validate", "status"]) | |
# parser.add_argument("--config", type=str, default="./config") | |
# | |
# args = parser.parse_args() | |
args = SimpleNamespace(option="validate", config='./config') | |
main(args) |