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

goldretriever.download_golds() fails #57

Closed
marcverhagen opened this issue Jul 3, 2024 · 6 comments
Closed

goldretriever.download_golds() fails #57

marcverhagen opened this issue Jul 3, 2024 · 6 comments
Labels
🐛B Something isn't working

Comments

@marcverhagen
Copy link

Bug Description

When running timeframe-eval/evaluate.py for chyrons the following snippets of code are executed:

GOLD_CHYRON_URL = "https://github.com/clamsproject/aapb-annotations/tree/cc0d58e16a06a8f10de5fc0e5333081c107d5937/newshour-chyron/golds"
goldretriever.download_golds(GOLD_CHYRON_URL)

The gold standard URL exists and leads to an html page. The problem is that the code in the goldretriever module seems to assume that the request returns a JSON object:

# Send a GET request to the repository URL and extract the HTML content
response = requests.get(gold_dir_url)
# github responses with JSON? wow
payload = json.loads(response.text)['payload']

I may make an obvious mistake since it seems that this should have worked for others.

Reproduction steps

Install requirements for timeframe evaluation:

cd timeframe-eval
pip install -r requirements.txt

Run the script:

python evaluate.py --mmif-dir preds\@swt\@3.1\@aapb-collaboration-7/ --chyron

You will be treated to this error

Traceback (most recent call last):
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/evaluate.py", line 196, in <module>
    ref_dir = goldretriever.download_golds(GOLD_CHYRON_URL)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/goldretriever.py", line 35, in download_golds
    payload = json.loads(response.text)['payload']
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 6)

Expected behavior

It should not break

Log output

Traceback (most recent call last):
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/evaluate.py", line 196, in <module>
    ref_dir = goldretriever.download_golds(GOLD_CHYRON_URL)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/goldretriever.py", line 35, in download_golds
    payload = json.loads(response.text)['payload']
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 6)


### Screenshots

_No response_

### Additional context

_No response_
@marcverhagen marcverhagen added the 🐛B Something isn't working label Jul 3, 2024
@clams-bot clams-bot added this to infra Jul 3, 2024
@github-project-automation github-project-automation bot moved this to Todo in infra Jul 3, 2024
@marcverhagen
Copy link
Author

It may be safer to use the API:

curl https://api.github.com/repos/clamsproject/aapb-annotations/git/trees/cc0d58e16a06a8f10de5fc0e5333081c107d5937

@keighrim
Copy link
Member

keighrim commented Jul 3, 2024

This has been fixed in the pypi version of the retriever
clamsproject/clams-utils@af58aaa released in https://pypi.org/project/clams-utils/240626/

Could you try importing the pypi version?

@marcverhagen
Copy link
Author

The error remains:

$ pip install clams-utils==240626
$ python evaluate.py --mmif-dir preds\@swt\@3.1\@aapb-collaboration-7/ --chyron
Traceback (most recent call last):
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/evaluate.py", line 196, in <module>
    ref_dir = goldretriever.download_golds(GOLD_CHYRON_URL)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/goldretriever.py", line 46, in download_golds
    payload = json.loads(response.text)['payload']
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 6)

While doing this I did realize that it was silly to use the --chyron option with the swt predictions so I changed the command

python evaluate.py --mmif-dir preds\@chyron-detection\@batch2/ --chyron

But the error remains.

I also replicated the above in the main branch (I failed to mention that all the above was on the 43-swt-eval branch), still the same error.

@keighrim
Copy link
Member

keighrim commented Jul 3, 2024

Look likes it's still the local retriever

  File "/Users/marc/Desktop/projects/clams/code/clamsproject/aapb-evaluations/timeframe-eval/goldretriever.py", line 46, in download_golds
    payload = json.loads(response.text)['payload']
              ^^^^^^^^^^^^^^^^^^^^^^^^^

Probably

from clams_utils.aapb import goldretriever

will change the library to use?

@marcverhagen
Copy link
Author

Duh! Yes, that got rid of the error.

What I really do not get is why the current code ever worked.

@keighrim
Copy link
Member

keighrim commented Jul 8, 2024

closing as fixed.

@keighrim keighrim closed this as completed Jul 8, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in infra Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛B Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants