Skip to content

Commit

Permalink
back to global list
Browse files Browse the repository at this point in the history
  • Loading branch information
davedavemckay committed Aug 15, 2024
1 parent d403e4b commit 8f0edd2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions echo-side/dags/process_new_zips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

from datetime import timedelta, datetime

bucket_names = []

def dl_bucket_names(**kwargs):
import json
import requests
bucket_names = []
global bucket_names
url = kwargs['url']
r = requests.get(url)
buckets = json.loads(r.text)
for bucket in buckets:
bucket_names.append(bucket['name'])
print(f'Bucket names found: {bucket_names}')
kwargs['ti'].xcom_push(key='bucket_names', value=bucket_names)
print(XComArg(get_bucket_names, key='bucket_names'))
# kwargs['ti'].xcom_push(key='bucket_names', value=bucket_names)
# return bucket_names

def print_bucket_name(bucket_name):
Expand Down Expand Up @@ -48,12 +49,12 @@ def print_bucket_name(bucket_name):
op_kwargs={'url':'https://raw.githubusercontent.com/lsst-uk/csd3-echo-somerville/main/echo-side/bucket_names/bucket_names.json'},
)

# print_bucket_name_task = [
# PythonOperator(
# task_id=f'print_bucket_name_{bucket_name}',
# python_callable=print_bucket_name,
# op_kwargs={'bucket_name': bucket_name},
# ) for bucket_name in XComArg('get_bucket_names', key='bucket_names')]
print_bucket_name_task = [
PythonOperator(
task_id=f'print_bucket_name_{bucket_name}',
python_callable=print_bucket_name,
op_kwargs={'bucket_name': bucket_name},
) for bucket_name in bucket_names]

# if len(bucket_names) > 0:
# print(f'Bucket names found: {bucket_names}')
Expand All @@ -72,5 +73,5 @@ def print_bucket_name(bucket_name):
# else:
# print('No bucket names found.')

get_bucket_names #>> print_bucket_name_task #>> process_zips_task
get_bucket_names >> print_bucket_name_task #>> process_zips_task

0 comments on commit 8f0edd2

Please sign in to comment.