I’m starting out with Airflow and was trying to convert one of the tutorials to TaskFlow.
@dag(
schedule=None,
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
catchup=False,
tags=["example"],
)
def tutorial_taskflow_api():
@task
def print_context(ds=None, **kwargs):
"""Print the Airflow context and ds variable from the context."""
print("::group::All kwargs")
pprint(kwargs)
print("::endgroup::")
print("::group::Context variable ds")
print(ds)
print("::endgroup::")
return "Whatever you return gets printed in the logs"
@task.virtualenv(task_id="virtualenv_python", requirements=["colorama==0.4.0"], system_site_packages=False)
def callable_virtualenv():
from time import sleep
from colorama import Back, Fore, Style
print(Fore.RED + "some red text")
print(Back.GREEN + "and with a green background")
print(Style.DIM + "and in dim text")
print(Style.RESET_ALL)
for _ in range(4):
print(Style.DIM + "Please wait...", flush=True)
sleep(1)
print("Finished")
print_context()
callable_virtualenv()
tutorial_taskflow_api()
if __name__ == "__main__":
tutorial_taskflow_api().test()
It seems to run, but Pycharm shows an warning on callable_virtualenv()
:
Parameter(s) unfilledPossible callees:(...: (ParamSpec("FParams")) -> FReturn)
All the tutorials I’m seeing, seem to have the methods defined like that. What am I missing? Not seeing anything on a google search.