Skip to content

Add OrbiterInclude+OrbiterRequirement helper utility#120

Merged
fritz-astronomer merged 5 commits intomainfrom
get_include_and_requirement
Dec 19, 2025
Merged

Add OrbiterInclude+OrbiterRequirement helper utility#120
fritz-astronomer merged 5 commits intomainfrom
get_include_and_requirement

Conversation

@fritz-astronomer
Copy link
Contributor

@fritz-astronomer fritz-astronomer commented Dec 19, 2025

  • feat(objects): Add helper to quickly get an orbiter include and requirement from a qualname of a py file

I found myself regularly needing to

  1. make a .py file for some function I wanted to include in Airflow, for a translation feature (in a special directory so it's separated from the translation, so the translations don't require airflow)
  2. needing to add a OrbiterInclude for that .py file
  3. needing to add a OrbiterRequirement to import it

I figured it'd be nice to have a shortcut.

Example:

Airflow Project Included File / Utility

# orbiter_translation/some_system/include/cool_utilities.py
from airflow import ...

def cool_utility_function(...):
    """this does some cool utility function to help an airflow operator or etc"""
    ...

Orbiter Translation

# orbiter_translation/some_system/translation.py

# note: `find_spec` is required for portability
# it could be compiled and running within a packed binary or .pyz
-  cool_utility_include = OrbiterInclude(
-    filepath='include/cool_utilities.py', 
-    contents=Path(find_spec("orbiter_translations.some_system.include.cool_utilities").origin).read_text()
- )
- cool_utility_function_import = OrbiterRequirement(
-    names=["cool_utility_function"],
-    module="include.cool_utilities"
- )
+ cool_utility_include, cool_utility_function_import =  OrbiterInclude.get_include_and_requirement(
+    include_module_qualname="orbiter_translation/some_system/include/cool_utilities",
+    import_names=["cool_utility_function"]
+ )
# orbiter_translation/some_system/translation.py
@task_rule
def some_rule(val: dict) -> OrbiterTask | None:
    if ... : 
        return OrbiterTask(
            imports=[cool_utility_function_import]
            orbiter_includes={cool_utility_include}
            ...
        )
    return None

@fritz-astronomer fritz-astronomer self-assigned this Dec 19, 2025
@fritz-astronomer fritz-astronomer added the enhancement New feature or request label Dec 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a helper method to the OrbiterInclude class that creates both an OrbiterInclude and OrbiterRequirement from a Python module's qualified name. This simplifies the process of including Python modules from the translation into the Airflow project.

Key changes:

  • Added get_include_and_requirement static method to OrbiterInclude class
  • Added TYPE_CHECKING import for forward reference to OrbiterRequirement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.79%. Comparing base (b3ee237) to head (9c3a2f5).
⚠️ Report is 75 commits behind head on main.

Files with missing lines Patch % Lines
orbiter/objects/include.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
+ Coverage   78.92%   82.79%   +3.86%     
==========================================
  Files          35       51      +16     
  Lines        1362     1988     +626     
==========================================
+ Hits         1075     1646     +571     
- Misses        287      342      +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

fritz-astronomer and others added 2 commits December 19, 2025 15:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: fritz-astronomer <80706212+fritz-astronomer@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: fritz-astronomer <80706212+fritz-astronomer@users.noreply.github.com>
Signed-off-by: fritz-astronomer <80706212+fritz-astronomer@users.noreply.github.com>
@fritz-astronomer fritz-astronomer merged commit 43ccd78 into main Dec 19, 2025
8 checks passed
@fritz-astronomer fritz-astronomer deleted the get_include_and_requirement branch December 19, 2025 21:35
fritz-astronomer added a commit that referenced this pull request Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants