Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
Minor fixes of typos and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Krystle Salazar committed Jul 2, 2021
1 parent 0c74c8b commit a4e4372
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/cc_catalog_airflow/templates/template_provider.py_template
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,26 @@ def main():
logger.info('Terminated!')


def _get_query_param(
def _get_query_params(
page_number=0,
default_query_param=None,
default_query_params=None,
):
if default_query_param is None:
default_query_param = DEFAULT_QUERY_PARAMS
query_param = default_query_param.copy()
query_param["page"] = str(page_number)
return query_param
if default_query_params is None:
default_query_params = DEFAULT_QUERY_PARAMS
query_params = default_query_params.copy()
query_params["page"] = str(page_number)
return query_params


def _get_items():
item_count = 0
page_number = 0
should_continue = True
while should_continue:
query_param = _get_query_param(page_number=page_number)
query_params = _get_query_params(page_number=page_number)

batch_data = _get_batch_json(
query_param=query_param
query_params=query_params
)
if isinstance(batch_data, list) and len(batch_data) > 0:
item_count = _process_item_batch(batch_data)
Expand All @@ -146,14 +146,14 @@ def _get_batch_json(
endpoint=ENDPOINT,
headers=None,
retries=RETRIES,
query_param=None
query_params=None
):
if headers is None:
headers = HEADERS
response_json = delayed_requester.get_response_json(
endpoint,
retries,
query_param,
query_params,
headers=headers
)
if response_json is None:
Expand Down Expand Up @@ -186,7 +186,7 @@ def _process_item_batch(items_batch):

def _extract_item_data(media_data):
"""
Extract data for individual image
Extract data for individual item

Required properties:
- foreign_landing_url
Expand Down Expand Up @@ -300,7 +300,7 @@ def _get_metadata(item):
Metadata may include: description, date created and modified at source,
categories, popularity statistics.
"""
# TODO: Add function to extract metadata from the image_data dictionary
# TODO: Add function to extract metadata from the item dictionary
# Do not includes keys without value
metadata = {}
some_other_key_value = item.get('some_other_key')
Expand All @@ -310,7 +310,7 @@ def _get_metadata(item):


def _get_tags(item):
"""What tags do we save???"""
# TODO: Add correct implementation of _get_tags
return item.get('tags')


Expand Down
2 changes: 1 addition & 1 deletion src/cc_catalog_airflow/templates/template_test.py_template
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_extract_{media_type}_data_handles_example_dict():

def test_get_tags():
item_data = {
"tags":['tag1', 'tag2']
"tags": ['tag1', 'tag2']
}
expected_tags = ['tag1', 'tag2']
actual_tags = {provider}._get_tags(item_data)
Expand Down

0 comments on commit a4e4372

Please sign in to comment.