AttributeError with get_news_story() in CODEBK with Dask

I am having a problem with Dask in CODEBK. Specifically, if I call get_news_story() from the Eikon API in a Dask worker I get the following error:

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-74-f3a00d0c8ed3> in <module>
21 22 for f in as_completed(fut):
---> 23 stories[f.result().id] = f.result()

/opt/conda/lib/python3.7/site-packages/distributed/client.py in result(self, timeout)
223 if self.status == "error":
224 typ, exc, tb = result
--> 225 raise exc.with_traceback(tb)
226 elif self.status == "cancelled":
227 raise result
<ipython-input-74-f3a00d0c8ed3> in __init__()
9 def __init__(self, idIn):
10 self.id = idIn;
---> 11 tmp = ek.get_news_story(self.id, raw_output=True)
12 self.headline = tmp['story']['headlineHtml']
13 self.story = tmp['story']['storyHtml']

/opt/conda/lib/python3.7/site-packages/refinitiv/dataplatform/legacy/news_request.py in get_news_story()
196 print (story)
197 """
--> 198 logger = DefaultSession.get_default_session().logger()
199 200 # check parameters type and values

AttributeError: 'NoneType' object has no attribute 'logger'

The following code in CODEBK should replicate the issue.

import refinitiv.dataplatform.eikon as ekek.set_app_key('DEFAULT_CODE_BOOK_APP_KEY')

from dask.distributed import Client, as_completedclient = Client("tcp://127.0.0.1:41045")

class story:    def __init__(self, idIn):
        self.id = idIn;
        tmp = ek.get_news_story(self.id, raw_output=True)
        self.headline = tmp['story']['headlineHtml']
        self.story = tmp['story']['storyHtml']

stories = {}
fut = []
currentHeadlines = ek.get_news_headlines(query='Language:LEN', count=10)
for col, row in currentHeadlines.iterrows():
    storyId = row['storyId']
    fut.append(client.submit(story, storyId))

for f in as_completed(fut):    stories[f.result().id] = f.result()

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @james123

    The error is similar to an issue when calling the get_news_story method without setting the application key.

    image

    I assume that Dask may not be able to access the ek object defined in the global.

Answers