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

Support for Windows #7

Closed
martomi opened this issue Apr 5, 2021 · 17 comments
Closed

Support for Windows #7

martomi opened this issue Apr 5, 2021 · 17 comments

Comments

@martomi
Copy link
Owner

martomi commented Apr 5, 2021

I personally don't have Windows to test and am not familiar with how the chia environment there is setup but can provide guidance on the steps necessary to add such support.

Here are some jumping off points if someone wants to take over:

  • We need a WIndowsLogConsumer that is analogous to the UNIX implementation in FileLogConsumer. It needs to replace the tail -F command with the analogous command for PowerShell.
    • Possibly something like Get-Content <log-file> -Tail <#-of-rows> -Wait
  • Add windows_log_consumer config. See here for an example. It needs to point to default path on Windows where debug.log is stored.
  • The project is using pathlib for handling the file paths. I believe this is compatible with Windows paths but needs to be tested.

I suggest doing a quick test by directly modifying the FileLogConsumer and changing the path in the config to see if there are any other showstoppers to make this work on Windows. That will already be very valuable feedback.

@skrustev
Copy link
Contributor

skrustev commented Apr 8, 2021

I was able to successfully run it without any issues on Windows 10 with the latest Python 3.9.4 Windows distribution.

The steps for running it are pretty much the same, only difference is that on Windows , the Python virtual environment is activated by running the ./.venv/Scripts/activate script directly.

  • If you are using VS Code, you can select the created virtual environment by pointing to the ./.venv/Scripts/python.exe and use the Python terminal to run the ChiaDog.

What else I probably had to set differently is the file_path in the config, since on Windows its usually distributed under C:/Users/<username>/.chia/mainnet/log/debug.log for example.

@stoatlemon
Copy link

stoatlemon commented Apr 20, 2021

Get the following error when trying to run on Windows 10 with Python 3.9.4 and modified debug.log file path.
@skrustev any idea what I'm missing ?

(venv) PS C:\Users\User\chiadog> python main.py --config config.yaml
[2021-04-20 16:41:07] [    INFO] --- Enabled file log consumer. (log_consumer.py:55)
[2021-04-20 16:41:07] [    INFO] --- Consuming log file from C:\Users\User\.chia\mainnet\log\debug.log (log_consumer.py:68)
[2021-04-20 16:41:07] [    INFO] --- Keep-alive check period: 300 seconds (keep_alive_monitor.py:34)
[2021-04-20 16:41:07] [    INFO] --- Initializing Pushover notifier. (pushover_notifier.py:13)
[2021-04-20 16:41:07] [    INFO] --- Enabled parser for harvester activity - eligible plot events. (harvester_activity_parser.py:32)
[2021-04-20 16:41:07] [    INFO] --- Enabled check for farming events. (harvester_activity_handler.py:75)
[2021-04-20 16:41:07] [    INFO] --- Enabled check for non-decreasing total plot count. (harvester_activity_handler.py:113)
[2021-04-20 16:41:07] [    INFO] --- Enabled check for time taken to respond to challenges. (harvester_activity_handler.py:145)
[2021-04-20 16:41:07] [    INFO] --- Enabled check for found proofs. (harvester_activity_handler.py:163)
Exception in thread Thread-1:
Traceback (most recent call last):
[2021-04-20 16:41:07] [    INFO] --- Enabled parser for finished signage points. (finished_signage_point_parser.py:28)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
[2021-04-20 16:41:07] [    INFO] --- Enabled check for finished signage points. (finished_signage_point_handler.py:58)
Traceback (most recent call last):
  File "C:\Users\User\chiadog\main.py", line 75, in <module>
    signal.pause()
AttributeError: module 'signal' has no attribute 'pause'
    self.run()
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\User\chiadog\src\chia_log\log_consumer.py", line 69, in _consume_loop
    f = subprocess.Popen(["tail", "-F", expanded_user_log_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

@skrustev
Copy link
Contributor

@stoatlemon Hm the error mainly seem to be that its not finding your specified debug.log file. Try with different path configuration like C:/Users/<user>/.chia/mainnet/log/debug.log or C:\\Users\\<user>\\.chia\\mainnet\\log\\debug.log.
For me any way works but for you something might be different, because I don't get any error if it doesn't find the file.

Also try commenting the last line in main.py since signal.pause() just in case. since its not really supported on windows, although it shouldn't prevent it from working.

@cipriani14
Copy link

I just tried to get this up and going, and everything seemed to work.. but when I try to launch main.py, here’s what I get:

PS C:\Users\MrCippy\chiadog> python3 main.py --config config.yaml [2021-04-25 12:26:40] [ INFO] --- Enabled file log consumer. (log_consumer.py:55) [2021-04-25 12:26:40] [ INFO] --- Consuming log file from C:\Users\mrcippy\.chia\mainnet\log\debug.log (log_consumer.py:68) [2021-04-25 12:26:40] [ INFO] --- Keep-alive check period: 300 seconds (keep_alive_monitor.py:45) Exception in thread Thread-1: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "C:\Users\MrCippy\chiadog\src\chia_log\log_consumer.py", line 69, in _consume_loop f = subprocess.Popen(["tail", "-F", expanded_user_log_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified [2021-04-25 12:26:40] [ INFO] --- Initializing Telegram notifier. (telegram_notifier.py:13) [2021-04-25 12:26:40] [ INFO] --- Enabled stats for daily notifications (stats_manager.py:38) [2021-04-25 12:26:40] [ INFO] --- Summary notifications will be sent out daily at 21 o'clock (stats_manager.py:48) [2021-04-25 12:26:40] [ INFO] --- Enabled parser for harvester activity - eligible plot events. (harvester_activity_parser.py:32) [2021-04-25 12:26:40] [ INFO] --- Enabled check for farming events. (time_since_last_farm_event.py:22) [2021-04-25 12:26:40] [ INFO] --- Enabled check for non-decreasing total plot count. (non_decreasing_plots.py:18) [2021-04-25 12:26:40] [ INFO] --- Enabled check for time taken to respond to challenges. (quick_plot_search_time.py:18) [2021-04-25 12:26:40] [ INFO] --- Enabled parser for finished signage points. (finished_signage_point_parser.py:28) [2021-04-25 12:26:40] [ INFO] --- Enabled check for finished signage points. (non_skipped_signage_points.py:20) Traceback (most recent call last): File "C:\Users\MrCippy\chiadog\main.py", line 80, in <module> signal.pause() AttributeError: module 'signal' has no attribute 'pause'

Any ideas? Thanks in advance.

@martomi
Copy link
Owner Author

martomi commented Apr 25, 2021

Hi @cipriani14 , two things:

  1. Please delete all lines in main.py after line 70. These are UNIX specific and not required for Windows. This will clean up the last error in the logs. The only side-effect will be that you'll need to forcefully kill the process when you decide to stop chiadog (you can do that by closing the terminal).
  2. The path to the log file you have in config.yaml seems to be incorrect. You can see that from the log:
FileNotFoundError: [WinError 2] The system cannot find the file specified

Did you use the pattern suggested C:/Users/<username>/.chia/mainnet/log/debug.log ? Also can you manually go to that folder and double-check that this debug.log file exists? If it's not there, it means that you haven't enabled the INFO logging on Chia.

@cipriani14
Copy link

Thanks, I have removed those lines and that did the trick for the last errors.

I can find my debug.log in the expected spot, and have chiadog pointed to it in the config.yaml file. When I paste the same path into File Explorer it opens the debug.log file as expected.

I have also tried the suggestion above by changing the path _C:/Users//.chia/mainnet/log/debug.log or C:\Users\\.chia\mainnet\log\debug.log with no luck.

I have to step out for a while, but will keep tinkering to get it working.

@stoatlemon
Copy link

I have the same issue as @cipriani14 , have tried :

C:\Users\User\.chia\mainnet\log\debug.log

C:/Users/User/.chia/mainnet/log/debug.log

Pasting either of those into explorer opens the debug log without issue.

Also tried this but it isn't a valid path:
C:\\Users\\User\\.chia\\mainnet\\log\\debug.log

@Akaino
Copy link

Akaino commented Apr 26, 2021

Was anyone able to solve this issue on windows? No path seems to be accepted. With shell=true (NOT recommended) there's no error but also no updates...

@martomi
Copy link
Owner Author

martomi commented Apr 26, 2021

Was anyone able to solve this issue on windows? No path seems to be accepted. With shell=true (NOT recommended) there's no error but also no updates...

Do you get number of plots detected when doing that? You can switch log level to DEBUG in chiadog's config.yaml to see updates, otherwise logs will be silent unless there's an issue detected (or changes in plots, found proofs, etc)

@angryBOT
Copy link

Was anyone able to solve this issue on windows? No path seems to be accepted. With shell=true (NOT recommended) there's no error but also no updates...

What to you mean by "With shell=true"? Is this a setting to be added in config.yaml? Thanks!

@skrustev
Copy link
Contributor

skrustev commented Apr 26, 2021

Ok I apologize, apparently both of the ways I tried running it using VS Code or Cmder, both had bash console emulators, which support the tail command.

Edit: Using powershell commands works so I could PR it as well. In the meantime you can replace Line 69 with:

f = subprocess.Popen(f"powershell.exe get-content {expanded_user_log_path} -tail 1 -wait", stdout=subprocess.PIPE, stderr=subprocess.PIPE)

@cipriani14
Copy link

@skrustev this fixed it for me. Thank you, all!

@angryBOT
Copy link

angryBOT commented Apr 27, 2021

The above fix works. I can start the main.py with my config.yaml and it detects the plots. But as soon as the time comes to create the daily stats, it crashes with a "division by zero".

PS C:\Python39\ChiaDog\chiadog> py main.py --config config.yaml [2021-04-27 12:24:30] [ INFO] --- Enabled file log consumer. (log_consumer.py:55) [2021-04-27 12:24:30] [ INFO] --- Consuming log file from C:\Users\pod\.chia\mainnet\log\debug.log (log_consumer.py:68) [2021-04-27 12:24:30] [ INFO] --- Keep-alive check period: 300 seconds (keep_alive_monitor.py:45) [2021-04-27 12:24:30] [ WARNING] --- Cannot process user events: 0 notifiers are enabled! (notify_manager.py:50) [2021-04-27 12:24:30] [ INFO] --- Enabled stats for daily notifications (stats_manager.py:38) [2021-04-27 12:24:30] [ INFO] --- Summary notifications will be sent out daily at 13 o'clock (stats_manager.py:48) [2021-04-27 12:24:30] [ INFO] --- Enabled parser for harvester activity - eligible plot events. (harvester_activity_parser.py:32) [2021-04-27 12:24:30] [ INFO] --- Enabled check for farming events. (time_since_last_farm_event.py:22) [2021-04-27 12:24:30] [ INFO] --- Enabled check for non-decreasing total plot count. (non_decreasing_plots.py:18) [2021-04-27 12:24:30] [ INFO] --- Enabled check for time taken to respond to challenges. (quick_plot_search_time.py:18) [2021-04-27 12:24:30] [ INFO] --- Enabled parser for finished signage points. (finished_signage_point_parser.py:28) [2021-04-27 12:24:30] [ INFO] --- Enabled check for finished signage points. (non_skipped_signage_points.py:20) [2021-04-27 12:24:36] [ INFO] --- Detected new plots. Farming with 22 plots. (non_decreasing_plots.py:23) Exception in thread Thread-3: Traceback (most recent call last): File "C:\Python39\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\Python39\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "C:\Python39\ChiaDog\chiadog\src\chia_log\handlers\daily_stats\stats_manager.py", line 87, in _run_loop self._send_daily_notification() File "C:\Python39\ChiaDog\chiadog\src\chia_log\handlers\daily_stats\stats_manager.py", line 77, in _send_daily_notification summary += "\n" + stat_acc.get_summary() File "C:\Python39\ChiaDog\chiadog\src\chia_log\handlers\daily_stats\stat_accumulators\signage_point_stats.py", line 37, in get_summary percentage_skipped = (self._skips_total / self._total) * 100 ZeroDivisionError: division by zero

Is there something wrong on my side? I tried with and without notifiers (tried Pushover and SMTP), but always get the same result.

Edit:
Can I simply add an if clause in signage_point_stats.py right at the beginning of "get_summary(self)" to set self._total to 1 if it is 0 at that point to avoid the division by zero? Or would that cause other malfunctions?

@martomi
Copy link
Owner Author

martomi commented Apr 27, 2021

@angryBOT this isn't windows specific. It's recently introduced bug reported also here #46

It happens only when running harvester separately from the node, that's a use-case that wasn't properly covered by tests. I'll aim to release a hot fix release later today.

Edit: You can just return empty string from get_summary() if total is 0.

@angryBOT
Copy link

angryBOT commented Apr 27, 2021

@martomi thanks a lot for replying quickly! Just additional info from my side: I am running the Chia GUI on one machine. So basically everything is running on localhost/127.0.0.1 (full node and harvester).
The finished plots are moved to a NAS, which is mounted to the same Windows machine, which is also farming.

Edit:
Okay, I did a noob workaround just to get it going. After Line 36 I added:

if self._total == 0: self._total = 1

I even do not know, what "signage points" are and wether they should be 0 or always higher. Nonetheless: I now get my daily summary via Pushover, which also contains reasonable numbers:

Proofs: 0 found
Search: 0.05s average, 0.42 s max (is that reasonable with 22 plots on a fast NAS in a gigabit network?)
Plots: 22
Eligible plots: 0.08 average
Skipped SPs: None

Should I remove the "workaround" or can it keep running like that without major issues?

Thanks again!

@martomi
Copy link
Owner Author

martomi commented Apr 27, 2021

@angryBOT You can keep the workaround but it's interesting that you're not seeing signage points on your node's logs.
If you're running full node + farmer + harvester on the same machine, I'm expecting that your logs will contain lines such as this one:

full_node chia.full_node.full_node: INFO     ⏲️  Finished signage point 

If that's not the case, then please open a separate issue describing the exact setup + chia version.

@martomi
Copy link
Owner Author

martomi commented Apr 27, 2021

I'm going to close this issue because it's now very noisy and we already had a major PR for support #43 merged. Some additional testing and contributions to documentations are necessary to officially announce the support but that should be handled in separate new issues or discussions

@martomi martomi closed this as completed Apr 27, 2021
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

No branches or pull requests

7 participants
@cipriani14 @martomi @skrustev @Akaino @angryBOT @stoatlemon and others