Commit d9862c58 authored by lintangsutawika's avatar lintangsutawika
Browse files

moved registry processes here

parent 484fa090
import os import os
import pathlib
import re import re
import collections
import functools
import inspect
import sys import sys
import yaml
import inspect
import pathlib
import functools
import subprocess
import collections
from typing import List from typing import List
from omegaconf import OmegaConf from omegaconf import OmegaConf
...@@ -253,8 +256,29 @@ def get_git_commit_hash(): ...@@ -253,8 +256,29 @@ def get_git_commit_hash():
return git_hash return git_hash
env = Environment(loader=BaseLoader, undefined=StrictUndefined) def get_yaml_config(yaml_path):
with open(yaml_path, "r") as f:
return yaml.load(f, yaml.Loader)
def RegistryDecorator():
registry = {}
def registrar(func):
if func.TASK_NAME is None:
name = func.__name__
else:
name = func.TASK_NAME
registry[name] = func
return func
registrar.all = registry
return registrar
register_task = RegistryDecorator()
env = Environment(loader=BaseLoader, undefined=StrictUndefined)
def apply_template(template, doc): def apply_template(template, doc):
rtemplate = env.from_string(template) rtemplate = env.from_string(template)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment