sertalpbilal / FPL-Optimization-Tools

A collection of tutorials and recipes to use optimization for winning Fantasy Premier League :)
Apache License 2.0
129 stars 45 forks source link

Unable to run multi_period_dev.py & 24/25 season changes to the multi_period.py #29

Open grecofin opened 1 month ago

grecofin commented 1 month ago

Hi @sertalpbilal,

I hope you are well.

First of all, thank you for the amazing content you are providing.

I have been following your YouTube Python optimization videos and I would like to incorporate the new features of 2024-2025 season to the multi_period.py code. I have seen the commit - Changes for 2024-2025 season you did earlier in the summer and I tried to add the extra lines of code to the multi_period.py code, but without success. Not sure if this has any value at all, but when I add the extra lines of code and comment out the respective old ones the FT variable always starts from its upper bound. So in the next gw it shows the upper bound (5 - under the new rules) as the number of free/available transfers which is a mistake.

Trying to understand what I was missing, I tried to run the multi_period_dev.py) code, but, again, without success. The steps I followed are the following:

  1. I cloned the repository in my PC.
  2. Comment out lines 45, 46
  3. Provided my password and login in lines 49, 50 as strings (not sure if relevant, but I also tried that)
  4. I followed the instructions in lines 66-69 and created the team.json file

When I ran the code the following error occured:

_PS C:\Users\User> & "C:/Users/User/AppData/Local/Programs/Python/Python39/python.exe" "c:/Users/User/FPL-Optimization-Tools/src/multi_period_dev.py" This method is provided for people who want to automate login. However with 2FA changes, it is unlikely to work, and I'd suggest using team.json method from now on as explained in README file. Login attempt failed, checking local file Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 974, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\Users\User\FPL-Optimization-Tools\src\multi_period_dev.py", line 1132, in my_data = get_my_data(session, team_id) File "c:\Users\User\FPL-Optimization-Tools\src\multi_period_dev.py", line 85, in get_mydata d = r.json() File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 978, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

To summarize, if it is not too much hustle, I would like to know what I'm missing and cannot run the multi_period_dev.py) code and if possible, how to incorporate the new changes to the multi_period.py code.

Apologies for the lengthy message.

Many thanks in advance.

grecofin commented 1 month ago

So for the first issue about incorporating the new rule changes to the multi_period.py code I think I figured it out. In the initial conditions we just have 'next_gw - 1', so if this is changed to 'next_gw' and follow all changes done to commit - Changes for 2024-2025 season I think it works.

image

Still cannot run multi_period_dev.py though.

sertalpbilal commented 1 month ago

Hello, sorry for the late reply. It looks like the JSON read is failing. Maybe your team.json file has invalid characters? Sometimes browsers show JSON data in a special format, so copy/paste breaks the JSON.

multi_period_dev is not meant to be run by itself (despite the main function in it). Does it work through run/solve_regular.py file?