Skip to content
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

Track without output bug #1170

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Conversation

dzumii
Copy link
Contributor

@dzumii dzumii commented Jun 20, 2024

Description
If track flag is used without specifying an output, an error is returned. This is because tracking requires a result parameter, which is the output of a run session. The error is thrown because the output being passed from run into the parameter is a generator object and not a csv file.

Changes Made
Wrote the generator file into a csv file, which is now read into the track function.

Status
Tracing now works without specifying output

To do
Make sure track flag works with all output formats (csv, tsv, json and h5) supported by ersilia

Related to #1131
Closes #1164

@DhanshreeA
Copy link
Member

@dzumii could you please resolve the conflicts on this branch? Thank you!

@dzumii dzumii force-pushed the track-without-outputflag branch 2 times, most recently from f4f4eaf to 72f7497 Compare June 24, 2024 07:10
@dzumii
Copy link
Contributor Author

dzumii commented Jun 24, 2024

@dzumii could you please resolve the conflicts on this branch? Thank you!

Done

@dzumii
Copy link
Contributor Author

dzumii commented Jun 24, 2024

@DhanshreeA
The tracking functionality now works without an output specified and with the csv, tsv and json output formats

def read_csv(file_path):
"""
Reads a CSV file and returns the data as a list of dictionaries.

:param file_path: Path to the CSV file.
:return: A list of dictionaries containing the CSV data.
"""
with open(file_path, mode='r') as file:

with open("output.csv", "w", newline="") as csvfile:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can write this file outside either directly in the track function or have a new function called something like "write_result_csv_when_not_a_file". Right now this function is misleading for two reasons:

  1. It's writing inside when it's supposed to only read csvs
  2. Every time the function is invoked, it will create a file called 'output.csv' even when an input file (or input) is passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made changes to this, the csv file is written inside the track function if result is a generator object

ersilia/core/tracking.py Show resolved Hide resolved
ersilia/core/tracking.py Show resolved Hide resolved
@DhanshreeA
Copy link
Member

DhanshreeA commented Jun 26, 2024

@dzumii LGTM! Minor documentation changes but rest is good!

Edit: I got confused, the PR is good to merge.

@DhanshreeA DhanshreeA merged commit 116fd3c into ersilia-os:master Jun 26, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🐛 Bug: Tracking functionality does not work when a result CSV file is not specified
2 participants