-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3482 update output format #5
base: main
Are you sure you want to change the base?
Conversation
remo87
commented
Nov 4, 2024
- add jq because polars can't handle the size of the file use subprocess to execute the jq
- Refactor homologue transformer to accept binary input and generate temporary file for processing
use subprocess to execute the jq
…mporary file for processing
def transform(src: BinaryIO, dst: BinaryIO) -> None: | ||
jq_command = '.genes | {"genes": map({id: .id, name: .name})}' | ||
|
||
# Generate a temporary file path tp store the source file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Generate a temporary file path tp store the source file | |
# Generate a temporary file path to store the source file |
temp_path = Path(f'/tmp/{uuid4()}.json') | ||
|
||
temp_path.write_bytes(src.read()) | ||
|
||
# Ejecuta jq con subprocess | ||
result = subprocess.run( | ||
['jq', jq_command, temp_path], | ||
capture_output=True, | ||
text=True | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temp_path = Path(f'/tmp/{uuid4()}.json') | |
temp_path.write_bytes(src.read()) | |
# Ejecuta jq con subprocess | |
result = subprocess.run( | |
['jq', jq_command, temp_path], | |
capture_output=True, | |
text=True | |
) | |
# Store the file and run jq on it | |
with tempfile.NamedTemporaryFile() as temp_file: | |
temp_file.write(src.read()) | |
result = subprocess.run( | |
['jq', jq_command, temp_file.name], | |
capture_output=True, | |
text=True, | |
) |
It's better to use tempfile
when creating temporary files for security reasons.
) | ||
|
||
# extract genes list | ||
genes_list = inputGenes.explode('genes').unnest('genes') | ||
# Verifica si el comando se ejecutó correctamente |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here!
|
||
# read id and name | ||
output = genes_list.select(["id","name"]) | ||
# # read id and name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# # read id and name | |
# read id and name |
|
||
# read id and name | ||
output = genes_list.select(["id","name"]) | ||
# Ejecuta jq con subprocess |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep comments in english