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

Avoid appending old log files #80

Open
bschilder opened this issue Dec 23, 2021 · 4 comments
Open

Avoid appending old log files #80

bschilder opened this issue Dec 23, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@bschilder
Copy link
Collaborator

Reprex

 gwas_paths <- MungeSumstats::import_sumstats(ids = meta$id, 
                                       save_dir = save_dir, 
                                       nThread = 50, 
                                       parallel_across_ids = TRUE,
                                       force_new_vcf = TRUE,
                                       force_new = TRUE,
                                       #### Record logs
                                       log_folder_ind = TRUE,
                                       log_mungesumstats_msgs = TRUE)

Issue: part 1

If you run format_sumstats with the log file options set, but then try to later re-munge some of those files, the log files from the previous runs get appended with the output from the new runs.

Here, you can see where it finished the old run and started the new run right around the middle ("Importing VCF file: ..."):

Screenshot 2021-12-23 at 14 12 33

Issue: part 2

Also, I noticed that If I start the above code, but then stop it midway, do some stuff in the R console , and then run it again, it will start recording my output from the console! (not the output of the munging process). This also gets appended to any pre-existing log files.

Screenshot 2021-12-23 at 14 11 26


Session info

@bschilder bschilder added the bug Something isn't working label Dec 23, 2021
@Al-Murphy
Copy link
Owner

I don't know if there is a good way around part 2 issue, this is an annoyance with the sink() function, you have to close connections to the file you are logging results to:

https://stackoverflow.com/questions/18730491/sink-does-not-release-file

@bschilder
Copy link
Collaborator Author

I wonder if closing all connections with this function might work:
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit

Specifically, i find base::closeAllConnections() to be the most comprehensive

@Al-Murphy
Copy link
Owner

Yep but you have to do it manually, if you quite MungeSumstats or it fails you have to call that yourself, no way for the function to I don't think

@bschilder
Copy link
Collaborator Author

Ok, I think I see what you mean. so like you have to wrap whatever function with on.exit(), as opposed to putting it within the function itself.

I'll keep looking around and see if there's a solution out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants