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

Incompatible with aiobotocore==1.4.0 #511

Closed
tshatrov opened this issue Aug 20, 2021 · 5 comments
Closed

Incompatible with aiobotocore==1.4.0 #511

tshatrov opened this issue Aug 20, 2021 · 5 comments

Comments

@tshatrov
Copy link

Current requirements are aiobotocore>=1.0.1 so the latest version 1.4.0 is installed. Unfortunately this version includes an incompatible change: aiobotocore.AioSession no longer works. For example this line of code. AioSession is now only available from aiobotocore.session. There might be other incompatibilities as well.

@martindurant
Copy link
Member

You were not alone to notice! Please see the linked PR.

@adam-s
Copy link

adam-s commented Aug 20, 2021

This is causing an error.

!pip install --quiet vectorbt
!pip install --quiet yfinance
!pip install --quiet --upgrade ta
!pip install --quiet s3fs
!pip install --quiet python-dotenv
!pip install --quiet tabulate

import pandas as pd
import numpy as np
import requests
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from itertools import combinations, product
import vectorbt as vbt
import yfinance as yf
import matplotlib.pyplot as plt
from tabulate import tabulate
import itertools
from collections import Counter
from sklearn import preprocessing, cluster, covariance
from tqdm.notebook import tqdm
import math
import os
module 'aiobotocore' has no attribute 'AioSession'
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-36-45e51c8fd379> in <module>()
      3 # 2021-07-22  150.300003  21.160000  ...  50.320000  200.539993
      4 # 2021-07-23  151.639999  21.221500  ...  50.740002  202.639999
----> 5 historical_prices = fetch_historical_prices(HISTORICAL_PRICES_DATE, from_cache=SP500_CACHE)
      6 historical_prices = historical_prices['Close']
      7 print(historical_prices)

14 frames
<ipython-input-34-1a4afac12dcf> in fetch_historical_prices(end, years, from_cache)
     11       print(e)
     12       pass
---> 13   SP500_companies = fetch_SP500_companies(date=format_date(end))
     14   symbols = [x.replace('.','-') for x in SP500_companies['Symbol']]
     15   historical_prices = pd.DataFrame(index=pd.DatetimeIndex([], name='Date'))

<ipython-input-32-5399ddcf5076> in fetch_SP500_companies(date)
      9   sp_data = pd.read_html(wiki_page)
     10   SP500_companies = pd.DataFrame(sp_data[0])
---> 11   SP500_companies.to_pickle(SP500_companies_path)
     12   return SP500_companies

/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py in to_pickle(self, path, compression, protocol)
   2674         from pandas.io.pickle import to_pickle
   2675 
-> 2676         to_pickle(self, path, compression=compression, protocol=protocol)
   2677 
   2678     def to_clipboard(

/usr/local/lib/python3.7/dist-packages/pandas/io/pickle.py in to_pickle(obj, filepath_or_buffer, compression, protocol)
     77     """
     78     fp_or_buf, _, compression, should_close = get_filepath_or_buffer(
---> 79         filepath_or_buffer, compression=compression, mode="wb"
     80     )
     81     if not isinstance(fp_or_buf, str) and compression == "infer":

/usr/local/lib/python3.7/dist-packages/pandas/io/common.py in get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode, storage_options)
    220         try:
    221             file_obj = fsspec.open(
--> 222                 filepath_or_buffer, mode=mode or "rb", **(storage_options or {})
    223             ).open()
    224         # GH 34626 Reads from Public Buckets without Credentials needs anon=True

/usr/local/lib/python3.7/dist-packages/fsspec/core.py in open(urlpath, mode, compression, encoding, errors, protocol, newline, **kwargs)
    436         newline=newline,
    437         expand=False,
--> 438         **kwargs,
    439     )[0]
    440 

/usr/local/lib/python3.7/dist-packages/fsspec/core.py in open_files(urlpath, mode, compression, encoding, errors, name_function, num, protocol, newline, auto_mkdir, expand, **kwargs)
    290     if "r" not in mode and auto_mkdir:
    291         parents = {fs._parent(path) for path in paths}
--> 292         [fs.makedirs(parent, exist_ok=True) for parent in parents]
    293     return OpenFiles(
    294         [

/usr/local/lib/python3.7/dist-packages/fsspec/core.py in <listcomp>(.0)
    290     if "r" not in mode and auto_mkdir:
    291         parents = {fs._parent(path) for path in paths}
--> 292         [fs.makedirs(parent, exist_ok=True) for parent in parents]
    293     return OpenFiles(
    294         [

/usr/local/lib/python3.7/dist-packages/fsspec/asyn.py in wrapper(*args, **kwargs)
     86     def wrapper(*args, **kwargs):
     87         self = obj or args[0]
---> 88         return sync(self.loop, func, *args, **kwargs)
     89 
     90     return wrapper

/usr/local/lib/python3.7/dist-packages/fsspec/asyn.py in sync(loop, func, timeout, *args, **kwargs)
     67         raise FSTimeoutError
     68     if isinstance(result[0], BaseException):
---> 69         raise result[0]
     70     return result[0]
     71 

/usr/local/lib/python3.7/dist-packages/fsspec/asyn.py in _runner(event, coro, result, timeout)
     23         coro = asyncio.wait_for(coro, timeout=timeout)
     24     try:
---> 25         result[0] = await coro
     26     except Exception as ex:
     27         result[0] = ex

/usr/local/lib/python3.7/dist-packages/s3fs/core.py in _makedirs(self, path, exist_ok)
    713     async def _makedirs(self, path, exist_ok=False):
    714         try:
--> 715             await self._mkdir(path, create_parents=True)
    716         except FileExistsError:
    717             if exist_ok:

/usr/local/lib/python3.7/dist-packages/s3fs/core.py in _mkdir(self, path, acl, create_parents, **kwargs)
    698                         "LocationConstraint": region_name
    699                     }
--> 700                 await self._call_s3("create_bucket", **params)
    701                 self.invalidate_cache("")
    702                 self.invalidate_cache(bucket)

/usr/local/lib/python3.7/dist-packages/s3fs/core.py in _call_s3(self, method, *akwarglist, **kwargs)
    235 
    236     async def _call_s3(self, method, *akwarglist, **kwargs):
--> 237         await self.set_session()
    238         s3 = await self.get_s3(kwargs.get("Bucket"))
    239         method = getattr(s3, method)

/usr/local/lib/python3.7/dist-packages/s3fs/core.py in set_session(self, refresh, kwargs)
    376 
    377         conf = AioConfig(**config_kwargs)
--> 378         self.session = aiobotocore.AioSession(**self.kwargs)
    379 
    380         for parameters in (config_kwargs, self.kwargs, init_kwargs, client_kwargs):

AttributeError: module 'aiobotocore' has no attribute 'AioSession'

@martindurant
Copy link
Member

Do you mean you still get the error on the main branch following the linked PR?

@adam-s
Copy link

adam-s commented Aug 20, 2021

Do you mean you still get the error on the main branch following the linked PR?

Sorry, I'm very new to python. I reset the Colab notebook and ran it again. It works perfect now.

@martindurant
Copy link
Member

no worries, @adam-s ; this all happened a bit unexpectedly from our point of view!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants