I've been searching for the solution here and here but no luck, I found a thread that discussing similar case with mine and eventually I decided to ask a question here, because it does not provide a solution to the case that I face.
How can I get a certain word in Python scripts (value of params) using bash script? for example, I have a Python script which has the following code:
from datetime import datetime, timedelta
from airflow import DAG
...
args = {
...
}
# A DAG for my_bigquery_pipeline -> this line should not be included in bash searching.
with DAG(dag_id='my_bigquery_pipeline', default_args=args,
schedule_interval='00 21 * * *') as dag:
from the above script I want to get the word my_bigquery_pipeline
whose line is not commented on, before I ask here, I've tried it with the following way:
sed -n '/^.*dag_id\s\+\/\(\w\+\).*$/s//\1/p' bigquery_pipeline.py
// and
sed "s/dag_id//2g" bigquery_pipeline.py
// and
egrep -oP '(?<=dag_id=/)\w+' bigquery_pipeline.py
unfortunately those method doesn't work for me, any help I'll appreciate! thanks!.