Skip to content

Commit

Permalink
Fix styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
greenw0lf committed Oct 11, 2024
1 parent 177c17a commit 1ea9e86
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 4 additions & 2 deletions asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def run(input_uri: str, output_uri: str, model=None) -> Optional[str]:
# 2. check if the input file is suitable for processing any further
transcode_output = try_transcode(input_path, asset_id, extension)
if transcode_output.error != "":
logger.error("The transcode failed to yield a valid file to continue with, quitting...")
remove_all_input_output(input_path, asset_id, extension, output_path)
logger.error(
"The transcode failed to yield a valid file to continue with, quitting..."
)
remove_all_input_output(input_path, asset_id, output_path)
return transcode_output.error
else:
input_path = transcode_output.transcoded_file_path
Expand Down
20 changes: 14 additions & 6 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class DownloadResult:
mime_type: str
provenance: dict
download_time: float = -1 # time (ms) taken to receive data after request
content_length: int = -1 # download_data.get("content_length", -1),
error: str = ""
content_length: int = -1 # download_data.get("content_length", -1),


def download_uri(uri: str) -> DownloadResult:
Expand All @@ -47,7 +47,7 @@ def http_download(url: str) -> DownloadResult:

# download if the file is not present (preventing unnecessary downloads)
start_time = time.time()
download_time = -1
download_time = -1.0

if not os.path.exists(input_file):
logger.info(f"File {input_file} not downloaded yet")
Expand All @@ -61,7 +61,11 @@ def http_download(url: str) -> DownloadResult:
logger.error(f"Could not download url: {response.status_code}")
download_time = (time.time() - start_time) * 1000
return DownloadResult(
input_file, mime_type, dict(), download_time, f"Input failure: Could not download url. Response code: {response.status_code}"
input_file,
mime_type,
dict(),
download_time,
f"Input failure: Could not download url. Response code: {response.status_code}",
)
file.write(response.content)
file.close()
Expand Down Expand Up @@ -100,7 +104,7 @@ def s3_download(s3_uri: str) -> DownloadResult:
mime_type = extension_to_mime_type(extension)

start_time = time.time()
download_time = -1
download_time = -1.0

if not os.path.exists(input_file):
s3 = S3Store(s3_endpoint_url)
Expand All @@ -114,10 +118,14 @@ def s3_download(s3_uri: str) -> DownloadResult:
logger.error("Failed to download input data from S3")
download_time = (time.time() - start_time) * 1000
return DownloadResult(
input_file, mime_type, dict(), download_time, "Input failure: Could not download S3 URI"
input_file,
mime_type,
dict(),
download_time,
"Input failure: Could not download S3 URI",
)

download_time = int((time.time() - start_time) * 1000) # time in ms
download_time = (time.time() - start_time) * 1000 # time in ms
else:
steps.append("Download skipped: input already exists")

Expand Down
6 changes: 5 additions & 1 deletion transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def try_transcode(input_path, asset_id, extension) -> TranscodeOutput:
# if the input format is not supported, fail
if not _is_transcodable(extension):
logger.error(f"input with extension {extension} is not transcodable")
return TranscodeOutput(input_path, dict(), f"Transcode failure: Input with extension {extension} is not transcodable")
return TranscodeOutput(
input_path,
dict(),
f"Transcode failure: Input with extension {extension} is not transcodable",
)

# check if the input file was already transcoded
transcoded_file_path = os.path.join(data_base_dir, "input", f"{asset_id}.mp3")
Expand Down

0 comments on commit 1ea9e86

Please sign in to comment.