MrPig91 / PSChiaPlotter

A repo for powershell module that helps Chia Plotting
MIT License
181 stars 47 forks source link

"Log Stats" history info in CSV fmt #111

Closed Jacek-ghub closed 3 years ago

Jacek-ghub commented 3 years ago

Would it be possible to save all done plots in a "history" file in a CSV format? The info that is right now in "Log Stats" would be really helpful.

Thank you, Jacek

MrPig91 commented 3 years ago

Hey Jacek, That is a good idea that I could add to the GUI. I do plan to add a page where you can see the stats for all plots in one view, and it would be easy to add and export-csv button. You can do this the powershell window with another function I wrote pretty easily though. See below for an example.

Get-ChiaPlottingStatistic | Export-CSV -Path C:\Users\myusername\documents\ChiaPlottingStats.csv -NoTypeInformation

Jacek-ghub commented 3 years ago

Thank you Syrius, that shell line works like a charm! Now Excel will have something to do as well :)

kszabok commented 3 years ago

So won't lost all statistic after restart program?

Jaga-Telesin commented 3 years ago

My experience in the past has been that PSChiaPlotter's own log files are cleared when exiting the GUI.

Jacek-ghub commented 3 years ago

Hi @Jaga-Telesin.

I needed to reboot my box. All the info that is produced by that PShell command is there, nothing was lost. My take is that ChiaPlotter is building those short logs from c:\users\uname.chia\mainnet\plotter stored logs (where the path suggested, those are build by chia.exe, not really PSChiaPlotter). However, when you create a new job, on the dst folder tab there is the same folder, so maybe it is a shared log folder.

On the other hand, when PSCP started, the lower/left stats are zeroed out, as those are potentially meant to reflect your current PSCP session.

MrPig91 commented 3 years ago

The logging stats for the plots are not deleted when the PSChiaPlotter GUI is closed, they are just not loaded back into the GUI when reopen, by design. I have on the roadmap to add these previous log stats in another tab or window if you want to visit past logs, but just haven't had the time to do so. I did write a function that kinda does this already called Show-ChiaPlottingStatistic. You just need to pass it an array of log file paths and it will open up a GUI with a datagrid. I haven't mentioned it because it was kinda a prototype.

The log file for the actual PSChiaPlotter GUI are located in the C:\users\username\appdata\local\pschiaplotter\logs folder and a new one is created every session and not deleted when the GUI closes.

Jacek-ghub commented 3 years ago

Hi @MrPig91,

I have just opened one log from that folder, and it only has:

[INFO]-[2021-06-22.15:54:23]-Staring PSChiaPlotter GUI - PID = 9468
PS C:\Windows\System32\WindowsPowerShell\v1.0> [INFO]-[2021-06-23.13:22:37]-PSChiaPlotter has been closed... Stopping Powershell process with PID of 9468

Do we need to somehow enable our runs to write to those logs? (Looking at the lower/left, I have "Log Level: Error" there.)

I updated today to v.45, but all five logs that I have there have the same thing.

Thank you, Jacek

MrPig91 commented 3 years ago

Those are the GUI logs, and look normal if the log level is set to ERROR. If you change the log level to INFO it will provide more info, but logging is still pretty basic in the GUI. As you mentioned earlier the actual plotting logs are stored by default to "c:\users\uname\chia\mainnet\plotter".

Jacek-ghub commented 3 years ago

Thank you Syrius!

A quick question. Can I modify PSChiaPlotter.psm1 while it is running (e.g., add something like "Write-Host "[INFO]-My Message""), or rather I need to restart it (as mentioned, this is the first time I see PS script)?

MrPig91 commented 3 years ago

You will need to restart the GUI every time you make a change to the module, usually. If you do want to add some Write-Host lines, you might need to add it to the ps1 files in the private folder since PSCP loads those functions every time it opens a new runspace. Normally you would only change the psm1 file, but since PSCP opens new runspaces I have to re-import private functions to use them.

I haven't tried it, but you might be able to update those ps1 files and then start a new job, since that will start a new runspace it should pick up those changes when it imports the functions. I haven't tested that out though as I always restart the GUI during testing.

Jacek-ghub commented 3 years ago

Thank you! I will play with that on an idle machine, then.

Jacek-ghub commented 3 years ago

I enabled Info logging in the running app. Works great, although at the moment every few seconds it spits out lines like that:

[INFO]-[2021-06-23.23:25:49]-Chia Volume Found: Letter H, UniqueId: \?\Volume{3f9f8c9e-aafc-4816-ab1d-a7d182b6199e}\

making the log basically worthless. Maybe that particular trace should be suppressed for now?

MrPig91 commented 3 years ago

I agree, I have been wanting remove that particular log (in place of it just say X drives found or something similar instead of a line for every drive found.

Jacek-ghub commented 3 years ago

Please forgive me my ignorance, but I cannot get any changes to show up.

I added to PSChiaPlotter.psm1 the following line: Write-Information "Test: Waiting on Temp Space" right after "$Queue.Status = "Waiting on Temp Space"" I started a job on tmp folder that doesn't have enough space (less than 200GB). I see that message in Job Queues. I see the time-stamp changed on that file. However, it doesn't show in the log. I did restart PSCP, I do it in the c:\program files\windowspowershell\modules\pschiaplotter\1.0.45

Is it possible, that OS is precompiling those scripts, and keeps them somewhere in a byte format? Therefore, changes to those files do nothing?

Jacek-ghub commented 3 years ago

I found on stack-overflow that once a module is imported, it resides in memory. I guess that may not be really correct, as that would mean that after reboot such module would be gone (unless all modules are reloaded on reboot). However, that implies that the byte-code option may be the case. To make those modules more secure, they are compiled to byte code, and stored as such, so no changes to the code will work.

Does that thing sound right?

MrPig91 commented 3 years ago

You can now view past plots stats on the Stats tab. This is a very basic version of what I have in mind for this feature, but the basic functionality is now there.