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

When running publisher, get errors in get_feeds() #122

Closed
trentmc opened this issue Sep 2, 2023 · 2 comments · Fixed by #125
Closed

When running publisher, get errors in get_feeds() #122

trentmc opened this issue Sep 2, 2023 · 2 comments · Fixed by #125
Assignees
Labels
Type: Bug Something isn't working

Comments

@trentmc
Copy link
Member

trentmc commented Sep 2, 2023

Describe the bug

Going through predictoor.md README, when I run

python pdr_backend/predictoor/main.py 1

Note: SUBGRAPH_URL=http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph

It fails in two possible ways. First way:

           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/feed.py", line 70, in dictToFeed
    trueval_submit_timeout=d["trueval_submit_timeout"],
                           ~^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'trueval_submit_timeout'

I just merged a branch into main. Now it fails a different way:

  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/approach1/predictoor_agent1.py", line 25, in __init__
    self.feeds: Dict[str, Feed] = self.config.get_feeds()  # [addr] : Feed
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/base_config.py", line 42, in get_feeds
    feed_dicts = query_feed_contracts(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 28, in wrapper
    check_types(*args, **kwargs)
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 21, in check_types
    raise TypeError(
TypeError: Expected type 'typing.Optional[str]' for attribute 'owners_string' but received type '<class 'list'>')

Discussion

For error 1: I'm pretty sure that I (Trent) introduced this when I introduced dictToFeed recently. It expects more data than it should have. That's where the fix lies too: to be looser about what it needs. E.g. fill in with good defaults.

Full traceback of error 1

(venv) trentmc@tlm-macbook: ~/code/pdr-backend $ python pdr_backend/predictoor/main.py 1
Traceback (most recent call last):
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/main.py", line 48, in <module>
    do_main()
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/main.py", line 31, in do_main
    do_main1()
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/approach1/main1.py", line 10, in do_main1
    p = PredictoorAgent1(config)
        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/approach1/predictoor_agent1.py", line 25, in __init__
    self.feeds: Dict[str, Feed] = self.config.get_feeds()  # [addr] : Feed
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/base_config.py", line 49, in get_feeds
    feeds = {addr: dictToFeed(feed_dict) for addr, feed_dict in feed_dicts.items()}
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/base_config.py", line 49, in <dictcomp>
    feeds = {addr: dictToFeed(feed_dict) for addr, feed_dict in feed_dicts.items()}
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/feed.py", line 70, in dictToFeed
    trueval_submit_timeout=d["trueval_submit_timeout"],
                           ~^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'trueval_submit_timeout'

Full traceback of error 2

(venv) trentmc@tlm-macbook: ~/code/pdr-backend $ python pdr_backend/predictoor/main.py 1
Traceback (most recent call last):
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/main.py", line 48, in <module>
    do_main()
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/main.py", line 31, in do_main
    do_main1()
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/approach1/main1.py", line 10, in do_main1
    p = PredictoorAgent1(config)
        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/predictoor/approach1/predictoor_agent1.py", line 25, in __init__
    self.feeds: Dict[str, Feed] = self.config.get_feeds()  # [addr] : Feed
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/pdr_backend/models/base_config.py", line 42, in get_feeds
    feed_dicts = query_feed_contracts(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 28, in wrapper
    check_types(*args, **kwargs)
  File "/Users/trentmc/code/pdr-backend/venv/lib/python3.11/site-packages/enforce_typing/decorator.py", line 21, in check_types
    raise TypeError(
TypeError: Expected type 'typing.Optional[str]' for attribute 'owners_string' but received type '<class 'list'>')
@trentmc trentmc added the Type: Bug Something isn't working label Sep 2, 2023
@trentmc trentmc self-assigned this Sep 2, 2023
@trentmc trentmc changed the title When running publisher, get KeyError trueval_submit_timeout When running publisher, get errors in get_feeds() Sep 2, 2023
@trizin trizin linked a pull request Sep 2, 2023 that will close this issue
@trentmc
Copy link
Member Author

trentmc commented Sep 2, 2023

In the PR, I fixed error 2 by tightening up what gets passed when and where: None vs [] vs str vs list vs tuple.

@trentmc
Copy link
Member Author

trentmc commented Sep 2, 2023

Wrt error 1, here's the dict that got passed into dictToFeed() right before the error:
{'name': 'XRP/USDT', 'address': '0x2d30d9b506f8df53058674a8be8722b073edf6a5', 'symbol': 'XRP/USDT', 'seconds_per_epoch': '300', 'seconds_per_subscription': '86400', 'last_submited_epoch': 0, 'pair': 'XRP/USDT', 'timeframe': '5m', 'source': 'binance', 'base': 'XRP', 'quote': 'USDT'}

trentmc added a commit that referenced this issue Sep 2, 2023
Fixes #122

Changes:
- bug fix: Make subgraph.py query feeds able to handle filters with value '', in addition to value None
- add robustness: env.py::parse_filters() now returns a tuple of list[str], not a list of list[str]|None
- bug fix: get_feeds() call to query_feed_contracts guarantees to pass in a str by concatenating lists
- bug fix: subgraph.py:query_feed_contracts() wasn't adding 'owner' to feed dict, fixed it
- bug fix: models/feed.py wasn't converting from str to int as needed. Fixed it
- bug fix: trueval_submit_timeout shouldn't be in feed_dict or Feed. Removed it. But ensured that trueval agent still saw it
- bug fix: feed.py::Feed property methods base() and quote() could only handle eg BTC-USDT but not BTC/USDT. Fixed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
1 participant