Skip to content

Commit

Permalink
Add JIL FileType (so it can be used by everywhere) (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-astronomer authored Nov 22, 2024
1 parent 60ce620 commit eec3e09
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion orbiter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from typing import Any, Tuple

__version__ = "1.3.2"
__version__ = "1.3.3"

version = __version__

Expand Down
22 changes: 22 additions & 0 deletions orbiter/file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit eec3e09

Please sign in to comment.