Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mokelumne/dags/fetch_from_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
description="The S3 connection."
),
"destination_directory": Param(
default="/srv/pa/city_arts/incoming",
default="/srv/pa/cityarts/ucb/incoming",
type="string",
description="The absolute directory path where files will be saved."
),
Expand Down Expand Up @@ -59,15 +59,15 @@ def validate_destination(params: dict):
@task
def get_bucket_file_names(params: dict) -> list:
"""Get a list of files for a given bucket. Can be filtered by prefix and extension"""
bucket = params["s3_bucket"]
s3_conn = params["s3_conn"]
bucket = params["s3_bucket"]
file_prefix = params["file_prefix"]
file_extension = params["file_extension"]

prefix = file_prefix.strip() if file_prefix else None
extension = file_extension.strip() if file_extension else None

file_names = list_bucket_files(bucket_name=bucket, conn_id = s3_conn, file_prefix=prefix, file_extension=extension)
file_names = list_bucket_files(conn_id = s3_conn, bucket_name=bucket, file_prefix=prefix, file_extension=extension)
if file_names:
for name in file_names:
logger.info("Found file: %s", name)
Expand All @@ -79,8 +79,8 @@ def get_bucket_file_names(params: dict) -> list:
@task(max_active_tis_per_dag=4)
def retrieve_file_from_bucket(file_key: str, params: dict):
"""Download from S3"""
bucket = params["s3_bucket"]
s3_conn = params["s3_conn"]
bucket = params["s3_bucket"]
dest_dir = params["destination_directory"]

try:
Expand Down
4 changes: 2 additions & 2 deletions mokelumne/util/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

logger = logging.getLogger(__name__)

def list_bucket_files(bucket_name: str, conn_id: str, file_prefix: str | None = None,
def list_bucket_files(conn_id: str, bucket_name: str, file_prefix: str | None = None,
file_extension: str | None = None) -> list:
"""Get a list of files for a given bucket"""

Expand All @@ -28,7 +28,7 @@ def list_bucket_files(bucket_name: str, conn_id: str, file_prefix: str | None =
return [key for key in keys if key.lower().endswith(extension.lower())]


def download_single_s3_file(file_key: str, bucket_name: str, conn_id: str, dest_dir: str) -> str:
def download_single_s3_file(file_key: str, conn_id: str, bucket_name: str, dest_dir: str) -> str:
"""
Downloads a single file from S3 to a local directory.
Returns the absolute path to the downloaded local file.
Expand Down
Loading