Skip to content

Commit

Permalink
use request_unsplash_api to request backend api (napi)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-p-esser committed Oct 8, 2023
1 parent 3cd0222 commit 242e4ad
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/prefect/ingest_photos_napi_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
parse_response,
prepare_proxy_adresses,
request_unsplash_api,
request_unsplash_napi,
)
from src.utils import load_env_variables, timer
from src.utils import load_env_variables


@flow(retries=3, retry_delay_seconds=10) # Subflow (2nd level)
Expand Down Expand Up @@ -79,7 +78,6 @@ def _upload_photo_metadata_as_blob(
timeout_seconds=120,
task_runner=ConcurrentTaskRunner(),
) # Subflow (2nd level)
@timer
def upload_photo_metadata_to_gcs(
response,
response_json: list[dict],
Expand Down Expand Up @@ -199,7 +197,6 @@ def write_request_log_to_bigquery(


@flow # Main Flow (1st level)
@timer
def ingest_photos_napi_gcs(
gcp_credential_block_name: str,
per_page: int,
Expand Down Expand Up @@ -258,7 +255,13 @@ def ingest_photos_napi_gcs(

# Actually request the data
logger.info("Request data of interest")
response = request_unsplash_napi("/photos", proxies, headers, params)
response = request_unsplash_api(
endpoint="/photos",
proxies=proxies,
headers=headers,
params=params,
base_url="https://unsplash.com/napi",
)
logger.info(f"Request headers: \n {pformat(dict(response.request.headers))}")
logger.info(f"Response headers: \n {pformat(dict(response.headers))}")

Expand Down

0 comments on commit 242e4ad

Please sign in to comment.