matteosdocsity commented on issue #30740:
URL: https://github.com/apache/airflow/issues/30740#issuecomment-1515089962
@potiuk sure this is the task code
`def print_hello_world(ds):
# with default airflow logging settings, DEBUG logs are ignored
logger.info("This log is at the level of INFO")
# each of these lines produces a log statement
print("This log is created with a print statement")
time.sleep(120)
print('Again, Hello World!')
return 'OK'`
and below the dag code
```
import sys
from os import path
from airflow import DAG
from airflow.models import Variable
from airflow.operators.python import PythonOperator
sys.path.append(path.dirname(path.abspath(__file__)))
from custom_operators.hello_world import print_hello_world
sys.path.append(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))
ENV = (Variable.get('ENV', default_var='dev') or 'test').lower()
from datetime import datetime, timedelta
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
start_date = datetime.strptime(Variable.get('DEFAULT_START_DATE',
default_var=yesterday),'%Y-%m-%d')
test = 1
args = {'owner': 'airflow', 'start_date': start_date, 'depends_on_past':
False}
resource_config = {"KubernetesExecutor": {"request_memory": "500Mi",
"limit_memory": "500Mi",
"request_cpu": "250m",
"limit_cpu": "250m"}}
with DAG(
dag_id='dag_for_test',
default_args=args,
schedule_interval='@once',
max_active_runs=1,
catchup=True, description="Simple task",
tags=['test']
) as dag:
suffix = '{{ macros.ds_add(ds, 1) | replace("-","/") }}'
hello = PythonOperator(
task_id='hello-task',
provide_context=True,
python_callable=print_hello_world,
op_kwargs={'suffix': suffix},
executor_config=resource_config,
dag=dag
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]