MicroStrategy / mstrio-py

Python integration for MicroStrategy
Apache License 2.0
90 stars 60 forks source link

TypeError in cube.py? #163

Open Beko2222 opened 8 months ago

Beko2222 commented 8 months ago

I have mstrio-py=11.3.12.101 installed an get an TypeError, when I try to do cube.to_dataframe(). Stacktrace:

Connection to MicroStrategy Intelligence Server has been established. Downloading: 0%| | 0/194 [00:00<?, ?it/s]Traceback (most recent call last): File "c:\test.py", line 30, in df = download_rebell_cube(conn) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\test.py", line 22, in download_rebell_cube return my_cube.to_dataframe() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ben\Python\venvs\testing\Lib\site-packages\mstrio\project_objects\datasets\cube.py", line 503, in to_dataframe future = self.__fetch_chunks_future( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ben\Python\venvs\testing\Lib\site-packages\mstrio\project_objects\datasets\cube.py", line 543, in __fetch_chunks_future return [ ^ File "C:\Users\ben\Python\venvs\testing\Lib\site-packages\mstrio\project_objects\datasets\cube.py", line 544, in cubes.cube_instance_id_coroutine( TypeError: cube_instance_id_coroutine() got an unexpected keyword argument 'connection'

mgorskiMicroStrategy commented 7 months ago

Hi @Beko2222, can you please share here larger part of your script so we can understand problem correctly? Are you using OlapCube or SuperCube objects?

Beko2222 commented 7 months ago

Hi @mgorskiMicroStrategy, its not very "large", but here you go:

from mstrio.project_objects import load_cube
def download_cube(conn: Connection) -> DataFrame:
    # CUBE_ID = "id_1"
    CUBE_ID = "id_2"
    my_cube = load_cube(connection=conn, cube_id=CUBE_ID)
    print(type(my_cube))
    return my_cube.to_dataframe()

When I use id_1, everything works fine. When i use id_2 i get the above error. In both cases, its a SuperCube (mstrio.project_objects.datasets.super_cube.SuperCube). When I view the Cubes in the Microstrategy Frontend, I can't spot any differences regarding their type etc. If I can provide any more info, let me know.

mgorskiMicroStrategy commented 7 months ago

Hi @Beko2222 script is really simple. I could't reproduce the issue. If you using cube from MicroStrategy Tutorial project sharing ID would be very useful.

Beko2222 commented 6 months ago

Sadly I can not share the Cube ID. Its a data cube with internal data hosted internally.

I mean, isn't it a simple/obvious error? When I look into the package code where the error ocurs I can see the following function call:

cubes.cube_instance_id_coroutine(
    future_session,
    connection=self._connection,
    cube_id=self._id,
    instance_id=instance_id,
    offset=_offset,
    limit=limit,
)

The errors states, that the kwarg connection is not known, which is true when I look at the function defintion:

def cube_instance_id_coroutine(
    future_session: 'FuturesSessionWithRenewal',
    cube_id: str,
    instance_id: str,
    offset: int = 0,
    limit: int = 5000,
):

Or am I missunderstanding something?

Edit: If I delete the kwarg connection=self.connection from the function call, everything works as expected.