uberfastman / fantasy-football-metrics-weekly-report

Command line application to create weekly reports (containing stats, metrics, and rankings) for Fantasy Football leagues on the following platforms: Yahoo, ESPN, CBS, Sleeper, Fleaflicker
GNU General Public License v3.0
202 stars 49 forks source link

[Bug] Error executing python main.py #124

Closed nguyenhaimd closed 4 years ago

nguyenhaimd commented 4 years ago

Description of Issue

When I run docker exec -it fantasy-football-metrics-weekly-report_app_1 python main.py I keep getting the error messages below. Any idea ?

image

Additional Information as Applicable

Fantasy Football Platform

Yahoo

League ID

626629

Operating System

Windows

Other

Docker WSL containers

uberfastman commented 4 years ago

Hi @nguyenhaimd thanks for opening the issue!

I've got a couple things for you to try to start out... first, make sure that the latest docker image has been build (you can do this by running docker-compose up -d --build).

Next, and this is my current suspicion, did you modify any files in the project before running it? That is to say, did you, by any chance, rename the original EXAMPLE-config.ini as opposed to making a copy of it and then renaming the copy?

If you could, from within the app directory, run the following:

docker exec -it fantasy-football-metrics-weekly-report_app_1 git status

The output of that should look something like:

On branch develop
Your branch is up to date with 'origin/develop'.

nothing to commit, working tree clean

Please let me know what it outputs! We'll get your sorted here, not to worry!

nguyenhaimd commented 4 years ago

Hi Wren,

Thanks so much for the super fast response. I didn't rename the original EXAMPLE-config.ini and did rename a copy of it per the instructions.

I rebuilt the image with docker-compose up -d --build

Output

PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball> docker-compose up -d --build
Building app
Step 1/7 : FROM python:3.8-slim
 ---> 62297c9f4e5c
Step 2/7 : LABEL "org.opencontainers.image.source"="https://github.com/uberfastman/fantasy-football-metrics-weekly-report"
 ---> Using cache
 ---> 271b0bdc5290
Step 3/7 : WORKDIR /app
 ---> Using cache
 ---> bd9949bca770
Step 4/7 : RUN apt-get update &&     apt-get install -y git &&     apt-get clean
 ---> Using cache
 ---> 7b65e523d940
Step 5/7 : COPY requirements.txt .
 ---> Using cache
 ---> 43eab5b1a814
Step 6/7 : RUN pip install -r requirements.txt
 ---> Using cache
 ---> a50a95f77139
Step 7/7 : CMD tail -f /dev/null
 ---> Using cache
 ---> 128cd14b831e

Successfully built 128cd14b831e
Successfully tagged nooksfantasyfootball_app:latest
Starting nooksfantasyfootball_app_1 ... done

I ran docker exec -it fantasy-football-metrics-weekly-report_app_1 git status

This is the output below

PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball> docker exec -it nooksfantasyfootball_app_1 git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .dockerignore
        modified:   .github/ISSUE_TEMPLATE/bug-report.md
        modified:   .github/ISSUE_TEMPLATE/feature-request.md
        modified:   .gitignore
        modified:   .travis.yml
        modified:   Dockerfile
        modified:   EXAMPLE-config.ini
        modified:   LICENSE
        modified:   README.md
        modified:   auth/espn/EXAMPLE-private.json
        modified:   auth/google/EXAMPLE-credentials.json
        modified:   auth/slack/EXAMPLE-token.json
        modified:   auth/yahoo/EXAMPLE-private.json
        modified:   calculate/bad_boy_stats.py
        modified:   calculate/beef_stats.py
        modified:   calculate/coaching_efficiency.py
        modified:   calculate/covid_risk.py
        modified:   calculate/metrics.py
        modified:   calculate/playoff_probabilities.py
        modified:   calculate/points_by_position.py
        modified:   calculate/season_averages.py
        modified:   dao/__init__.py
        modified:   dao/base.py
        modified:   dao/espn.py
        modified:   dao/fleaflicker.py
        modified:   dao/sleeper.py
        modified:   dao/yahoo.py
        modified:   dev-requirements.txt
        modified:   docker-compose.yml
        modified:   integrations/drive_integration.py
        modified:   integrations/slack_integration.py
        modified:   main.py
        modified:   report/builder.py
        modified:   report/data.py
        modified:   report/logger.py
        modified:   report/pdf/charts/bar.py
        modified:   report/pdf/charts/line.py
        modified:   report/pdf/charts/pie.py
        modified:   report/pdf/generator.py
        modified:   requirements.txt
        modified:   resources/documentation/README.md
        modified:   resources/documentation/descriptions.py
        modified:   resources/files/EXAMPLE-report.pdf
        modified:   resources/files/crime-categories.json
        modified:   resources/google_quickstart.py
        modified:   resources/reportlab_template.py
        modified:   resources/run_in_virtualenv.command
        modified:   resources/setup.sh
        modified:   tests/test_features.py
        modified:   utils/app_config_parser.py
        modified:   utils/report_tools.py

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball>
uberfastman commented 4 years ago

Ah, I just ran into this with another user literally a day ago. Did you by any chance use the GitHub Desktop client to clone the project @nguyenhaimd ? I see that your project directory is named NooKsFantasyFootball, which leads me to believe you might have used the client and then given it that name.

As you can see, due to the renaming, it things that you've modified, well, every single file. I recently added in some git-based functionality to let users know when their local app installation has fallen behind the latest on GitHub, but it has definitely caused a few headaches as I worked out the kinks of that.

Anyway, looking back at your output.. I notice it says "On branch master", so I think that has revealed the error. Just the other day I renamed the master branch to main, and deleted the old master branch. That means it's gone, and can't be retrieved from git anymore. First off, as of now the app needs to be run from the develop branch, and secondly, I think we can fix this by running the below:

docker exec -it nooksfantasyfootball_app_1 git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main

Let me know if we've made any progress!

nguyenhaimd commented 4 years ago

Yes I did use the Git Desktop client to clone it.

image

Should I start over and use the default app name to avoid any issues ?

I ran the commands you suggested. See output below.

PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball> docker exec -it nooksfantasyfootball_app_1 git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball> docker exec -it nooksfantasyfootball_app_1 python main.py
Traceback (most recent call last):
  File "main.py", line 30, in <module>
    up_to_date = check_for_updates()
  File "/app/utils/report_tools.py", line 220, in check_for_updates
    num_commits_behind_develop = len(list(project_repo.iter_commits("develop..origin/develop")))
  File "/usr/local/lib/python3.8/site-packages/git/objects/commit.py", line 277, in _iter_from_process_or_stream
    finalize_process(proc_or_stream)
  File "/usr/local/lib/python3.8/site-packages/git/util.py", line 329, in finalize_process
    proc.wait(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/git/cmd.py", line 408, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git rev-list develop..origin/develop --
  stderr: 'fatal: bad revision 'develop..origin/develop'
'
PS C:\Users\nguye\OneDrive\Desktop\NooKsFantasyFootball>
uberfastman commented 4 years ago

Well, I did get it working for the other guy who used the Git Desktop client the other day so in theory you shouldn't have to start over.

Did you switch to the develop branch though to run the app? Make sure the current branch is on develop before trying to run it.

nguyenhaimd commented 4 years ago

Hey Wren. I started over and kept the default name and its working fine now. I am an idiot. Thanks so much for your assistance. Will send some beer $ your way.

Appreciate all your help.

uberfastman commented 4 years ago

No worries @nguyenhaimd, you're just gotten to be part of my "live testing" haha. Every time I think I've covered everything in my documentation, somebody comes up with something I need to add. In this case, in the span of two days I've had two people run into the same issue, so I should clearly add a note in the instructions to keep the project name the same if using the Git Desktop client.

I'm glad it's all working for you now, and thanks for the donation, I'm really grateful!