From eec3e09d463ee04614ecb37eb71e57641a38efa7 Mon Sep 17 00:00:00 2001 From: fritz-astronomer <80706212+fritz-astronomer@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:00:35 -0500 Subject: [PATCH] Add JIL FileType (so it can be used by everywhere) (#35) --- orbiter/__init__.py | 2 +- orbiter/file_types.py | 22 ++++++++++++++++++++++ pyproject.toml | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/orbiter/__init__.py b/orbiter/__init__.py index 6e75fd7..9c4a580 100644 --- a/orbiter/__init__.py +++ b/orbiter/__init__.py @@ -3,7 +3,7 @@ import re from typing import Any, Tuple -__version__ = "1.3.2" +__version__ = "1.3.3" version = __version__ diff --git a/orbiter/file_types.py b/orbiter/file_types.py index 82dac79..52794fd 100644 --- a/orbiter/file_types.py +++ b/orbiter/file_types.py @@ -12,6 +12,8 @@ ) from pydantic.v1 import validator +from jilutil.jil_parser import JilParser + class FileType(BaseModel, ABC, arbitrary_types_allowed=True): """**Abstract Base** File Type @@ -181,6 +183,26 @@ class FileTypeYAML(FileType): dump_fn: ClassVar[Callable[[dict], str]] = yaml.safe_dump +def dump_jil(_: dict) -> str: + raise NotImplementedError("JIL dumping is not implemented yet.") + + +class FileTypeJIL(FileType): + """JIL File Type + + :param extension: JIL + :type extension: Set[str] + :param load_fn: custom JIL loading function + :type load_fn: Callable[[str], dict] + :param dump_fn: custom JIL dumping function + :type dump_fn: Callable[[dict], str] + """ + + extension: ClassVar[Set[str]] = {"JIL"} + load_fn: ClassVar[Callable[[str], dict]] = JilParser(None).parse_jobs_from_str + dump_fn: ClassVar[Callable[[dict], str]] = dump_jil + + if __name__ == "__main__": import doctest diff --git a/pyproject.toml b/pyproject.toml index 22b46c5..e0ae2fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,10 @@ dependencies = [ # alternative # "ruamel.yaml" + # for parsing JIL - fork + # original @ https://github.com/mscribellito/jilutil + "jilutil @ https://github.com/astronomer/jilutil/archive/refs/heads/master.zip", + # to render timezone-aware DAGs "pendulum", "tzdata", # for timezone data, if system doesn't have it?