Skip to content

Commit

Permalink
operation: compression: Added outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer290399 authored and pdxjohnny committed Jul 14, 2021
1 parent 7d4da8f commit 97f39e9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dffml/operation/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async def compress(
with open(input_file_path, "rb") as f_in:
with compression_cls.open(output_file_path, "wb") as f_out:
shutil.copyfileobj(f_in, f_out)
return {"output_path": output_file_path}

return compress

Expand All @@ -44,6 +45,7 @@ async def decompress(input_file_path: str, output_file_path: str):
with compression_cls.open(input_file_path, "rb") as f_in:
with open(output_file_path, "wb") as f_out:
shutil.copyfileobj(f_in, f_out)
return {"output_path": output_file_path}

return decompress

Expand All @@ -58,20 +60,26 @@ async def decompress(input_file_path: str, output_file_path: str):
decompressed_file_path = Definition(
name=f"decompressed_{extension}_file_path", primitive="str"
)
compressed_output_file_path = Definition(
name=f"compressed_output_{extension}_file_path", primitive="str"
)
decompressed_output_file_path = Definition(
name=f"decompressed_output_{extension}_file_path", primitive="str"
)

compress = op(
inputs={
"input_file_path": decompressed_file_path,
"output_file_path": compressed_file_path,
},
outputs={},
outputs={"output_path": compressed_output_file_path},
)(make_compress(extension, compression_cls))
decompress = op(
inputs={
"input_file_path": compressed_file_path,
"output_file_path": decompressed_file_path,
},
outputs={},
outputs={"output_path": decompressed_output_file_path},
)(make_decompress(extension, compression_cls))

setattr(sys.modules[__name__], f"{extension}_compress", compress)
Expand Down

0 comments on commit 97f39e9

Please sign in to comment.