tools

द्वारा astronomer

इस रिपॉजिटरी में कमांड-लाइन टूल्स और हेल्पर स्क्रिप्ट्स (bin/ में मौजूद चीज़ें) लिखते, संपादित करते या समीक्षा करते समय उपयोग करें। इसमें टूल्स कहाँ रहते हैं, आर्गुमेंट पार्सिंग…

npx skills add https://github.com/astronomer/astronomer --skill tools

Writing tools in bin/

Repo tooling (setup scripts, one-off utilities, anything a human or CI invokes directly) lives in bin/ and follows a few rules so tools are discoverable, self-documenting, and safe to run by accident.


Critical Rules

  1. Tools live in bin/ as executable scripts: a shebang (#!/usr/bin/env python3 for Python) plus chmod +x. Python tools run via uv run bin/<tool>.py.
  2. Every tool parses arguments with argparse (or the language equivalent) so --help works and every argument is self-documenting. Parse arguments as the first thing main() does.
  3. --help and insufficient/invalid arguments must do no work. They print usage and exit before any side effect. argparse gives this for free as long as parsing happens before any side-effecting code.
  4. A tool must not perform a destructive or state-mutating operation by default. Merely running it (or running it to read --help) must not create/delete Kubernetes objects, write/delete files, call external services, or change the active context.

Non-destructive by default

The failure mode to design against: someone runs bin/some-tool.py (or bin/some-tool.py --help) expecting it to be inert or to print help, and instead it mutates whatever ambient context it finds — the current kube context, the current directory, a live cluster.

The rule that prevents it: do not give a safe-looking default to any argument that determines where a mutation lands (a namespace, a cluster, a path, a target host). Make those arguments required with no default, so a bare or accidental invocation aborts before doing anything.

With argparse, a required=True argument with no default means:

  • tool (no args) → prints usage to stderr and exits non-zero, before main() reaches any side effect.
  • tool --help → prints help and exits 0.
  • tool --namespace foo ... → runs, because the caller was explicit about the target.

Worked example: bin/setup-forgejo-ca.py

This script creates and deletes Kubernetes Secrets in a cluster. It originally defaulted its namespaces (astronomer, git-forgejo). Running bin/setup-forgejo-ca.py --help to read the help text would instead have run the whole thing against the reader's current kube context — a potentially destructive surprise.

The fix was to make the namespaces required, with no defaults:

def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument("--platform-namespace", required=True, help="...")
    parser.add_argument("--forgejo-namespace", required=True, help="...")
    return parser.parse_args()


def main() -> None:
    args = parse_args()  # aborts here on a bare run or --help, before any kubectl
    ...  # cluster mutations only happen after this line

Now --help and a bare run both abort before touching the cluster, and any real run has to name its target namespaces on purpose.

Automation still works

Making the target arguments required does not break automated callers — it just moves the intent to the caller, where it belongs. The automated invocation passes the values explicitly. For example, the git-sync-private-ca scenario's pre_helm_scripts entry names the namespaces:

pre_helm_scripts:
  - bin/setup-forgejo-ca.py --platform-namespace astronomer --forgejo-namespace git-forgejo

Checklist for a new or edited tool

  • Lives in bin/, is executable, has the right shebang.
  • Uses argparse; --help works and does nothing else.
  • Arguments that decide where a mutation lands are required with no default.
  • Side effects run only after arguments parse successfully.
  • Fails loudly on error (non-zero exit), and is idempotent (safe to re-run) where practical.
  • Callers (CI, scenario manifests, other scripts) pass the required arguments explicitly.

astronomer की और Skills

airflow-state-store
astronomer
Persists task and asset state across retries and DAG runs using Airflow 3.3's AIP-103 key/value stores (`task_state_store`, `asset_state_store`) and the…
creating-openlineage-extractors
astronomer
कस्टम OpenLineage एक्सट्रैक्टर, असमर्थित Airflow ऑपरेटरों और जटिल लिनिएज परिदृश्यों के लिए। दो दृष्टिकोण: अपने स्वामित्व वाले ऑपरेटरों में सीधे OpenLineage विधियाँ जोड़ें (अनुशंसित), या तीसरे पक्ष के ऑपरेटरों के लिए कस्टम एक्सट्रैक्टर बनाएं जिन्हें आप संशोधित नहीं कर सकते। एक्सट्रैक्टर तीन बिंदुओं पर ऑपरेटर निष्पादन को इंटरसेप्ट करते हैं: स्थिर लिनिएज के लिए निष्पादन से पहले, रनटाइम-निर्धार
debugging-dags
astronomer
व्यवस्थित मूल कारण विश्लेषण और विफल Airflow DAGs के लिए संरचित जांच कार्यप्रवाहों के साथ सुधार। चार-चरणीय निदान प्रक्रिया के माध्यम से मार्गदर्शन करता है: विफलता की पहचान करें, त्रुटि विवरण निकालें, प्रासंगिक जानकारी एकत्र करें, और कार्रवाई योग्य सुधार कदम प्रदान करें। विफलताओं को चार प्रकारों (डेटा, कोड, बुनियादी ढांचा, निर्भरता) में वर्गीकृत करता है ताकि जांच पर ध्यान केंद्रित किया जा सके और उपयुक्त सुधार स
delegating-to-otto
astronomer
Drives Astronomer's Otto agent (`astro otto`) as a delegated sub-agent for Airflow, dbt, and data-engineering work. Use when the user explicitly asks to "use…
deploying-airflow
astronomer
Airflow DAG और प्रोजेक्ट्स को डिप्लॉय करें। इसका उपयोग तब करें जब उपयोगकर्ता कोड डिप्लॉय करना चाहता है, DAG पुश करना चाहता है, CI/CD सेट अप करना चाहता है, प्रोडक्शन में डिप्लॉय करना चाहता है, या डिप्लॉयमेंट रणनीतियों के बारे में पूछता है…
deploying-go-sdk-bundles
astronomer
संकलित Airflow Go SDK बंडलों को बनाता, पैक करता और तैनात करता है ताकि ExecutableCoordinator उन्हें चला सके। उपयोग तब करें जब उपयोगकर्ता Go टास्क बंडल को संकलित करना चाहता है, पूछता है…
testing-dags
astronomer
Airflow DAGs के लिए पुनरावृत्त परीक्षण-डीबग-फिक्स चक्र, जिसमें व्यापक विफलता निदान शामिल है। DAG चलाने और पूरा होने की प्रतीक्षा करने के लिए af runs trigger-wait <dag_id> से शुरू करें; किसी प्री-फ्लाइट जांच की आवश्यकता नहीं है। विफलता पर, व्यापक विफलता सारांश के लिए af runs diagnose और विशिष्ट कार्यों से त्रुटि विवरण का निरीक्षण करने के लिए af tasks logs का उपयोग करें। कस्टम कॉन्फ़िगरेशन, टाइमआउट और पुनः प्रयास प्रयासों का समर्थन करता है; स
tracing-downstream-lineage
astronomer
डाउनस्ट्रीम डेटा वंशावली का पता लगाएं ताकि तालिकाओं या DAGs को संशोधित करने से पहले परिवर्तन के प्रभाव का आकलन किया जा सके। स्रोत कोड खोज, व्यू निर्भरताओं और BI टूल कनेक्शनों के माध्यम से लक्ष्य तालिका या DAG के प्रत्यक्ष उपभोक्ताओं की पहचान करता है। तालिकाओं से लेकर डैशबोर्ड और ML मॉडल तक सभी डाउनस्ट्रीम प्रभावों को मैप करने वाला एक पूर्ण निर्भरता ट्री बनाता है। हितधारक संचार और परीक्षण को प्र