Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
9 3 2 3

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 ek

ek.set_app_key('DEFAULT_CODE_BOOK_APP_KEY')

from dask.distributed import Client, as_completed

client = 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()
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apicodebookdask
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
80k 257 52 75

@james123

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

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


1619418554761.png (49.6 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@jirapongse.phuriphanvichai Thank you. I'll try scattering the ek object and see if that works.

I still haven't got around to checking this. I will update here when I have

Thanks, this helped.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.