gazpachoking / trainaspower

Convert TrainAsOne training plans from pace to power, and upload them to FinalSurge for use in Stryd workouts.
21 stars 5 forks source link

ERROR | trainaspower.main:main:100 - Could not load next Train as One workout. Created taocalendar.html for debugging. #17

Closed thepiper18 closed 2 years ago

thepiper18 commented 3 years ago

As discussed on Reddit. I now installed it on Linux, and the same error happens, possibly because my next workout is a race (?). In my TAO settings, I already turned off the "run back" setting too, although TrainAsPower seems to still be looking for it... (?)

Log file (personal data deleted for privacy reasons):

2021-10-27 17:21:02.848 | INFO     | trainaspower.trainasone:get_next_workouts:40 - Fetching next TrainAsOne workout.
2021-10-27 17:21:05.861 | INFO     | trainaspower.trainasone:get_workout:93 - Converting TrainAsOne workout to power.
2021-10-27 17:21:05.862 | DEBUG    | trainaspower.stryd:suggested_power_range_for_distance:61 - Getting suggested power range for 13.0 kilometer
2021-10-27 17:21:06.946 | DEBUG    | trainaspower.main:main:99 - Error
Traceback (most recent call last):

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 130, in convert_steps
    out_step.length = parse_duration(step.text)
    │                 │              │    └ <property object at 0x7f21f4be6cc0>
    │                 │              └ <Element 'li' class=('pace-VERY_EASY',)>
    │                 └ <function parse_duration at 0x7f21f4bf0c10>
    └ <trainaspower.models.ConcreteStep object at 0x7f21f48a6ac0>

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 229, in parse_duration
    raise ValueError(f"No duration found in text `{step_string}`")

ValueError: No duration found in text `Run back`

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 94, in get_workout
    w.steps = list(convert_steps(steps, config))
    │              │             │      └ Config(stryd_email='myemail@provider.com', stryd_password='xxxxxxxxxxxxxx', trainasone_email='myemail@provider.com', ...
    │              │             └ [<Element 'li' class=('pace-FAST',)>, <Element 'li' class=('pace-VERY_EASY',)>]
    │              └ <function convert_steps at 0x7f21f4bf09d0>
    └ <trainaspower.models.Workout object at 0x7f21f48cb640>

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 133, in convert_steps
    distance = parse_distance(step.text)
               │              │    └ <property object at 0x7f21f4be6cc0>
               │              └ <Element 'li' class=('pace-VERY_EASY',)>
               └ <function parse_distance at 0x7f21f4bf0b80>

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 219, in parse_distance
    raise ValueError(f"No distance found in `{text}`")

ValueError: No distance found in `Run back`

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 49, in get_next_workouts
    yield get_workout(workout_url, date, config)
          │           │            │     └ Config(stryd_email='myemail@provider.com', stryd_password='xxxxxxxxxxxxxxx', trainasone_email='myemail@provider.com', ...
          │           │            └ datetime.datetime(2021, 10, 30, 0, 0)
          │           └ 'https://beta.trainasone.com/plannedWorkout?targetUserId=xxxxxxxxxxxxxxxx&workoutId=xxxxxxxxxxxxx...
          └ <function get_workout at 0x7f21f4bf0940>

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 97, in get_workout
    raise FindWorkoutException(
          └ <class 'trainaspower.trainasone.FindWorkoutException'>

trainaspower.trainasone.FindWorkoutException: Error finding workout steps: ('No distance found in `Run back`',)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "<string>", line 1, in <module>

> File "/home/user/Desktop/TrainAsPower/trainaspower/main.py", line 87, in main
    for wo in islice(
              └ <class 'itertools.islice'>

  File "/home/user/Desktop/TrainAsPower/trainaspower/trainasone.py", line 54, in get_next_workouts
    raise FindWorkoutException(
          └ <class 'trainaspower.trainasone.FindWorkoutException'>

trainaspower.trainasone.FindWorkoutException: Error finding next TaO workout: Error finding workout steps: ('No distance found in `Run back`',)
2021-10-27 17:21:06.950 | ERROR    | trainaspower.main:main:100 - Could not load next Train as One workout. Created taocalendar.html for debugging.

Thanks a lot for your feedback & advice, congrats once again for making this great tool possible! :-)

jahofmann commented 3 years ago

With the latest update to TrainasOne they added the option to download the workout in JSON format. Using the JSON instead of parsing the website should be more reliable. Speeds are given in m/s and all the steps seem to be properly named.

For reference, this is a simple economy workout:

{
    "workoutName": "Some Workout",
    "sport": "RUNNING",
    "workoutProvider": "TrainAsONE",
    "workoutSourceId": "TrainAsONE",
    "steps": [
        {
            "type": "WorkoutStep",
            "stepOrder": 1,
            "intensity": "WARMUP",
            "durationType": "TIME",
            "durationValue": 300.0,
            "targetType": "SPEED",
            "targetValue": 3,
            "targetValueLow": 2.5,
            "targetValueHigh": 3.5
        },
        {
            "type": "WorkoutStep",
            "stepOrder": 2,
            "intensity": "ACTIVE",
            "durationType": "TIME",
            "durationValue": 1380.0,
            "targetType": "SPEED",
            "targetValue": 4,
            "targetValueLow": 3.8,
            "targetValueHigh": 4.2
        }
    ]
}

@gazpachoking Are you interested in a pull request for this?

gazpachoking commented 3 years ago

@jahofmann Oh that's awesome, converting to this would be great. I'd love a pull request for that!

jahofmann commented 3 years ago

@thepiper18 Does the race also come with a workout file attached? If so, could you provide me the JSON?

thepiper18 commented 3 years ago

workout-548S-trail-race-casual.txt @jahofmann Yes, it does. I'll copy it below and also try to attach the file, please let me know if it doesn't work (knock on wood):

{"workoutName":"W548S Lekfara country run 13km 17.4℃ 2.24U","description":"","sport":"RUNNING","workoutProvider":"TrainAsONE","workoutSourceId":"TrainAsONE","steps":[{"type":"WorkoutStep","stepOrder":1,"intensity":"ACTIVE","durationType":"TIME","durationValue":4130.0,"targetType":"SPEED","targetValue":3.148751894456083,"targetValueLow":3.0542893376224,"targetValueHigh":3.243214451289765},{"type":"WorkoutStep","stepOrder":2,"intensity":"COOLDOWN","description":"Run back","durationType":"OPEN","targetType":"OPEN"}]}

Many thanks!!

gazpachoking commented 3 years ago

Oh, it looks like it's the 'run back' step that's causing issues.

thepiper18 commented 3 years ago

I had the feeling it could be, yeah. However, I tried turning off the run back option in TAO, but I still get the same issue, although the new workout available in TAO does not shows it anymore. Weird...

gazpachoking commented 3 years ago

Run back step shouldn't be hard to handle, I'm going to wait until we switch over to the new JSON method though, as everything should be cleaner and easier to maintain when we don't have to scrape anymore.

thepiper18 commented 3 years ago

Ok, so a quick update after my race. As my legs are sore, I decided to rest in from of the computer and re-ran the Linux trainaspower version (the classic, not the JSON recent commit).

The next two workouts were imported correctly. The third workout is, again, a race, and I received an error message.

The log is as follows:

2021-10-31 13:25:10.563 | INFO     | trainaspower.trainasone:get_next_workouts:40 - Fetching next TrainAsOne workout.

2021-10-31 13:25:13.579 | INFO     | trainaspower.trainasone:get_workout:93 - Converting TrainAsOne workout to power.

2021-10-31 13:25:19.040 | INFO     | trainaspower.finalsurge:add_workout:140 - Posting workout `552V 6 min Assessment run` to Final Surge

2021-10-31 13:25:21.162 | INFO     | trainaspower.trainasone:get_workout:93 - Converting TrainAsOne workout to power.

2021-10-31 13:25:24.491 | INFO     | trainaspower.finalsurge:add_workout:140 - Posting workout `553U Economy run` to Final Surge

2021-10-31 13:25:27.017 | INFO     | trainaspower.trainasone:get_workout:93 - Converting TrainAsOne workout to power.

2021-10-31 13:25:28.088 | ERROR    | trainaspower.main:main:100 - Could not load next Train as One workout. Created taocalendar.html for debugging.
gazpachoking commented 2 years ago

Is this still an issue with the new JSON handling?

jamorris commented 2 years ago

I just ran into this "Could not load next Train as One workout" issue right after changing from TAO free to the paid plan. That was the only change I made. It worked well under the free plan. This is the error:

trainaspower.trainasone.FindWorkoutException: Error finding next TaO workout: Error finding workout steps: ("'NoneType' object has no attribute 'group'",)

This is my next run:

image
jamorris commented 2 years ago

Reverting to v0.6.5 fixed the issue. I don't have "run back" enabled. Update: I disabled "Adjust pace for temperature" and that fixed the issue for v0.7.3. With adjust pace for temperature active, the JSON file has the "℉" symbol. Could that be causing an error? Image: adjust pace for temperature inactive on left, active on right.

image
gazpachoking commented 2 years ago

Reverting to v0.6.5 fixed the issue. I don't have "run back" enabled. Update: I disabled "Adjust pace for temperature" and that fixed the issue for v0.7.3. With adjust pace for temperature active, the JSON file has the "℉" symbol. Could that be causing an error? Image: adjust pace for temperature inactive on left, active on right.

Thanks @jamorris. Should be fixed now in the latest version.