GoldenCheetah / GoldenCheetah

Performance Software for Cyclists, Runners, Triathletes and Coaches
http://goldencheetah.org/
GNU General Public License v2.0
1.8k stars 447 forks source link

Python fixes crashing GC 3.5 on Windows 10 #3459

Closed ansluk closed 4 years ago

ansluk commented 4 years ago

I'm trying to use Python fixes to clean up fit files exported from Movescount web site that the GC fit importer doesn't like so much. Running the python scripts crashes GC.

fix_movescount.py script will crash GC when running without writing something before in the python console of "New python fixes"

  1. Launch Golden Cheetah with test activities already imported.
  2. Edit -> Python fixes -> Fix Movescount
  3. GC crash. (crash_2231_240520.log)

Script will run if python console is used before.

  1. Launch Golden Cheetah with test activities already imported.
  2. Edit -> Python fixes -> New Python Fix
  3. Write "foo = 1" and hit Enter in bottom left python console.
  4. Close New Python Fix window.
  5. Edit -> Python fixes -> Fix Movescount
  6. The python fix script runs as expected.

Thanks, Anders

version

fix_movescount.py.txt

configglobal-pyfixes.ini.txt

test_activities.zip

crash_2231_240520.log

crash_2231_240520.dmp.zip

amtriathlon commented 4 years ago

I have not looked in detail nor reproduced this issue yet, but looking at fix_movescount.py shows it doesn’t work on the open activity, but it loop over all activities of certain type applying other data processors, I am not sure it is an expected or supported behavior. The GC way of doing this is to enable those data processors to run on import, this makes the process automatic and avoid repeated application.

ansluk commented 4 years ago

Aha, I see my python processor will appear in the list of automatic import processors. I did not realize this. When removing looping over several activities from the python script and setting the script as an automatic import processor in Options -> Data fields -> Processing Everything works as expected.

amtriathlon commented 4 years ago

In that case you can use a filter expression in the top-right filter box, see https://github.com/GoldenCheetah/GoldenCheetah/wiki/UG_Special-Topics_Formula-Syntax-and-Expressions#postprocessprocessor-expression

amtriathlon commented 4 years ago

The call to activities with a filter is causing the crash, that method is intended to be run in a Python Chart context, and it is crashing when it doesn't have one. Currently to work on other activities than the one on which the Data Processor is running is not supported, we need to find a way to avoid this crash, but this is not recommended. What you can do in this case is to use a Python fix to run the DPs you want, in the order you like, but on only on the current activity. From your example:

GC.postProcess('Fix GPS errors')
#GC.postProcess('Estimate Distance Values')
GC.postProcess('Fix Speed from Distance')
GC.postProcess('Fix HR Spikes')

works for me with your test data.