Skip to content

Commit

Permalink
update output file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
appukuttan-shailesh committed Aug 12, 2024
1 parent be27e43 commit d9b89d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .osparc/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ outputs:
description: path to the converted file
type: data:*/*
fileToKeyMap:
data.json: output_1
output.zip: output_1

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ services:
file","description":"path of file to be converted","type":"data:*/*"},"input_2":{"displayOrder":2.0,"label":"target
format","description":"required format of the output file","type":"ref_contentSchema","contentSchema":{"title":"target_format","default":"json","enum":["csv","json","yaml","xls","xlsx","nwb","parquet","feather","pkl","xml","toml","h5","hdf5"]}}}}'
io.simcore.outputs: '{"outputs":{"output_1":{"displayOrder":1.0,"label":"converted
file","description":"path to the converted file","type":"data:*/*","fileToKeyMap":{"data.json":"output_1"}}}}'
org.label-schema.build-date: 2024-08-11T20:55:08+0000
file","description":"path to the converted file","type":"data:*/*","fileToKeyMap":{"output.zip":"output_1"}}}}'
org.label-schema.build-date: 2024-08-12T07:47:35+0000
org.label-schema.schema-version: '1.0'
org.label-schema.vcs-ref: ''
org.label-schema.vcs-url: ''
Expand Down
18 changes: 10 additions & 8 deletions service.cli/execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ echo "PWD folder content:"
ls -al

# display the contents of log_output_filepath.txt
echo "Content of log_output_filepath.txt:"
echo "$(cat log_output_filepath.txt)"
# echo "Content of log_output_filepath.txt:"
# echo "$(cat log_output_filepath.txt)"

cp "$(cat log_output_filepath.txt)" $OUTPUT_FOLDER
# cp "$(cat log_output_filepath.txt)" $OUTPUT_FOLDER
# echo "TEST DATA" > $OUTPUT_FOLDER/outputs.txt

cp output.zip $OUTPUT_FOLDER

#TODO: Replace following
cat > "${OUTPUT_FOLDER}"/outputs.json << EOF
{
"output_1":"$(cat log_output_filepath.txt)"
}
EOF
# cat > "${OUTPUT_FOLDER}"/outputs.json << EOF
# {
# "output_1":"$(cat log_output_filepath.txt)"
# }
# EOF
13 changes: 9 additions & 4 deletions src/file_format_converter/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import argparse
import os
import zipfile

import pandas as pd
import json
Expand All @@ -9,7 +11,6 @@
import pickle
import xml.etree.ElementTree as ET
import toml
import os

class FileConverter:
def __init__(self, input_file):
Expand Down Expand Up @@ -108,9 +109,13 @@ def convert(self, output_file):
self.read_file()
self.write_file(output_file)
print(f"Converted {self.input_file} to {output_file} successfully.")
# write output file path to a file
with open('log_output_filepath.txt', 'w') as f:
f.write(output_file)
# now create a zip of the output file as output.zip
with zipfile.ZipFile('output.zip', 'w') as z:
z.write(output_file)
print(f"Zipped {output_file} to output.zip successfully.")
# # write output file path to a file
# with open('log_output_filepath.txt', 'w') as f:
# f.write(output_file)

# Example Usage
if __name__ == "__main__":
Expand Down

0 comments on commit d9b89d6

Please sign in to comment.