Skip to content

Commit

Permalink
Apply @kaxil's suggestion for better visualisation
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajkoti committed Aug 20, 2024
1 parent d355144 commit 3548153
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
37 changes: 21 additions & 16 deletions docs/_ext/traverse_operators_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def collect_elements(
directory_path: str,
files: list[str],
element_type: str,
elements_list: list[tuple[str, str, str, str]],
elements_list: list[tuple[str, bool, str, str]],
current_module_path: str,
):
"""
Expand All @@ -51,7 +51,8 @@ def collect_elements(
if element_type in element_name and ASYNC_SUBSTRING in element_name:
module = importlib.import_module(module_import_path)
cls = getattr(module, element_name)
is_deprecated = "Yes" if getattr(cls, "is_deprecated", False) else "No"
is_deprecated = bool(getattr(cls, "is_deprecated", False))
# is_deprecated = "✅" if getattr(cls, "is_deprecated", False) else "❌"
post_deprecation_replacement = str(getattr(cls, "post_deprecation_replacement", ""))
elements_list.append(
(element_name, is_deprecated, module_import_path, post_deprecation_replacement)
Expand Down Expand Up @@ -91,21 +92,23 @@ def run(self):
"<table>"
"<th>#</th>"
"<th>Operator name</th>"
"<th>Is deprecated</th>"
"<th>Deprecated</th>"
"<th>Import path</th>"
"<th>Post deprecation replacement</th>"
)
for index, operator in enumerate(operators, start=1):
class_def_link = operator[1].replace(".", "/") + "/index.html#" + operator[1] + "." + operator[0]
class_def_link = operator[2].replace(".", "/") + "/index.html#" + operator[2] + "." + operator[0]
operators_html += (
f"<tr>"
f"<td>{index}</td>"
f"<td><span><a id={operator[0]}>{operator[0]}</a></span></td>"
f"<td style='text-align: center;'>{operator[1]}</td>"
f"<td><span><pre><code class='python'>from {operator[2]} import {operator[0]}</code></pre></span></td>"
f"<td><span><pre><code class='python'>{operator[3]}</code></pre></span></td>"
f"</tr>"
)
if operator[1]:
operators_html += "<td style='text-align: center;'>✅</td>"
operators_html += f"<td><b>Old Path:</b>\n <span><pre><code class='python'>from {operator[2]} import {operator[0]}</code></pre></span>\n <b>New Path:</b> \n<span><pre><code class='python'>{operator[3]}</code></pre></span></td>"
else:
operators_html += "<td style='text-align: center;'>❌</td>"
operators_html += f"<td><span><pre><code class='python'>from {operator[2]} import {operator[0]}</code></pre></span></td>"
operators_html += "</tr>"
# The below script generates the URL for the class definition by extracting the selected doc version from
# the current browser URL location.
operators_html += (
Expand All @@ -122,21 +125,23 @@ def run(self):
"<table>"
"<th>#</th>"
"<th>Sensor name</th>"
"<th>Is deprecated</th>"
"<th>Deprecated</th>"
"<th>Import path</th>"
"<th>Replacement import path</th>"
)
for index, sensor in enumerate(sensors, start=1):
class_def_link = sensor[1].replace(".", "/") + "/index.html#" + sensor[1] + "." + sensor[0]
class_def_link = sensor[2].replace(".", "/") + "/index.html#" + sensor[2] + "." + sensor[0]
sensors_html += (
f"<tr>"
f"<td>{index}</td>"
f"<td><span><a id={sensor[0]}>{sensor[0]}</a></span></td>"
f"<td style='text-align: center;'>{sensor[1]}</td>"
f"<td><span><pre><code class='python'>from {sensor[2]} import {sensor[0]}</code></pre></span></td>"
f"<td><span><pre><code class='python'>{sensor[3]}</code></pre></span></td>"
f"</tr>"
)
if sensor[1]:
sensors_html += "<td style='text-align: center;'>✅</td>"
sensors_html += f"<td><b>Old Path:</b>\n <span><pre><code class='python'>from {sensor[2]} import {sensor[0]}</code></pre></span>\n <b>New Path:</b> \n<span><pre><code class='python'>{sensor[3]}</code></pre></span></td>"
else:
sensors_html += "<td style='text-align: center;'>❌</td>"
sensors_html += f"<td><span><pre><code class='python'>from {sensor[2]} import {sensor[0]}</code></pre></span></td>"
sensors_html += "</tr>"
sensors_html += (
f"<script> "
f"var base_url = '' + window.location.pathname.split('/providers/')[0] + '/_api/';"
Expand Down
4 changes: 2 additions & 2 deletions docs/providers/operators_and_sensors_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Available Operators and Sensors

Since ``astronomer-providers>=1.19.0``, most of the operators and sensors are now deprecated and their instantiations
are proxied to their upstream Apache Airflow providers' deferrable counterparts.
Please check the deprecation status in the ``Is deprecated`` column in the tables below. If the status is ``Yes``,
then you're suggested to use the replacement suggestion provided in the ``Post deprecation replacement`` column and
Please check the deprecation status in the ``Deprecated`` column in the tables below. If the status is ``Yes``,
then you're suggested to use the replacement suggestion provided as ``New Path`` in the ``Import path`` column and
pass the ``deferrable=True`` param to the operator/sensor instantiation in your DAG.

.. traverse_operators_sensors::
Expand Down

0 comments on commit 3548153

Please sign in to comment.