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

Refactor store_model() method to improve safety and efficiency #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krishnakumarbhat
Copy link

@krishnakumarbhat krishnakumarbhat commented Mar 9, 2023

The store_model() method was updated to improve safety and efficiency by using the 'with' statement to automatically close the file after writing, and by checking if the model has been updated before storing it on disk. This avoids potential data loss or file corruption, and reduces unnecessary writes to disk. Specifically, the 'open()' function calls were replaced with 'with open()', and a conditional check was added to only store the model on disk if it has been updated.

i changed this because The initial code was not as safe as the second one because it uses the open() function to open the file and write to it, but it does not use the with statement to automatically close the file when the operation is completed or an error occurs. This means that if an error occurs during the write operation, the file may not be closed properly, which could lead to data loss or file corruption
@eldraco
Copy link
Collaborator

eldraco commented Mar 10, 2023

Hi @krishnakumarbhat . Thanks for this, yes, it is a good change. However, the commit message is very ambiguous since you didn't updated the bin files. Can you please update the commit message to reflect the real change?

@krishnakumarbhat krishnakumarbhat changed the title updated model.bin and scaler.bin #224 Refactor store_model() method to improve safety and efficiency #224 Mar 11, 2023
@krishnakumarbhat krishnakumarbhat changed the title Refactor store_model() method to improve safety and efficiency #224 Refactor store_model() method to improve safety and efficiency #245 Mar 11, 2023
@krishnakumarbhat krishnakumarbhat changed the title Refactor store_model() method to improve safety and efficiency #245 Refactor store_model() method to improve safety and efficiency Mar 11, 2023
@krishnakumarbhat
Copy link
Author

krishnakumarbhat commented Mar 11, 2023

sorry sir for inconvenience. i have implemented the recommended changes as per your suggestion. Specifically, I have made the code more robust and efficient by utilizing the 'with' statement to ensure automatic file closing after writing. Moreover, I have added a check to verify whether the model has been updated before storing it on disk, which will help prevent any possible data loss or file corruption. Additionally, this modification will also reduce the number of writes to disk, which enhances performance.

Thank you for your valuable support .Kindly let me know if there are any further adjustments that I need to make or if you have any feedback on my work.

@krishnakumarbhat
Copy link
Author

hi sir, sorry for this issue I am unaware of what is this test case problem because I have just changed the python code and wrote it in another but why is it showing the error . Would you be able to assist me in understanding the error message and guide me on how to fix the issue? I would really appreciate your help. Thank you

@AlyaGomaa
Copy link
Collaborator

@krishnakumarbhat it means when running slips on these 2 files
dataset/test7-malicious.pcap
dataset/test8-malicious.pcap
Slips had errors.
so you can fix them and I will run the checks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants