MicroStrategy / mstrio-py

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

Create SuperCube function Issue #150

Closed kkadu closed 10 months ago

kkadu commented 1 year ago

Iserver Version - 11.3.0660 mstrio - 11.3.10.103

I am trying to create a supercube using the create() function, but I get the below error. Btw, I also tried using the parameter force='True' during create step, to skip checking the cube but that does not help.

Steps:

  1. Add a table to the cube using .add_table and then show table with dataset.tables. Here dataset is my SuperCube object.

Output:

[{'table_name': 'Table1',
  'data_frame':   project_id project_name
  0          x            x,
  'update_policy': 'replace',
  'to_attribute': ['project_id', 'project_name'],
  'to_metric': []}]
  1. Pass the create command dataset.create() to create it and get the below error. It seems that it is trying to get the definition of the cube along with the create command, not sure if it is latency but the command does create the cube successfully however we get an error when it tries to check it.

Output:

Error getting cube 787381114045C9876BC6E3A6897965C8 definition.
I-Server Error ERR004, The object does not exist in the metadata.

Detailed Error

Error getting cube 787381114045C9876BC6E3A6897965C8 definition.
I-Server Error ERR004, The object does not exist in the metadata.
Ticket ID: 30407a50d12645eba0cd313314e29a74
---------------------------------------------------------------------------
IServerError                              Traceback (most recent call last)
Cell In[44], line 1
----> 1 dataset.create()

File ~\Documents\Anaconda\envs\mstrio\lib\site-packages\mstrio\project_objects\datasets\super_cube.py:475, in SuperCube.create(self, folder_id, auto_upload, auto_publish, chunksize, force, attribute_forms)
    472     self.update(chunksize=chunksize, auto_publish=auto_publish)
    474 # after creating super cube fetch definition and create filter object
--> 475 self._get_definition()

File ~\Documents\Anaconda\envs\mstrio\lib\site-packages\mstrio\project_objects\datasets\cube.py:697, in _Cube._get_definition(self)
    692 """Get the definition of a cube, including attributes and metrics.
    693 
    694 Implements GET /v2/cubes/<cube_id>.
    695 """
    696 if self._id is not None:
--> 697     _definition = cubes.cube_definition(
    698         connection=self._connection, id=self._id
    699     ).json()
    700     full_attributes = _definition['definition']['availableObjects'][
    701         'attributes'
    702     ]
    703     full_metrics = _definition['definition']['availableObjects']['metrics']

File ~\Documents\Anaconda\envs\mstrio\lib\site-packages\mstrio\utils\error_handlers.py:61, in ErrorHandler.__call__.<locals>.inner(*args, **kwargs)
     59     handler_kwargs = self._get_resp_handler_kwargs(kwargs)
     60     error_msg = self._replace_with_values(error_msg, func, *args, **kwargs)
---> 61     response_handler(response, error_msg, **handler_kwargs)
     62 return response

File ~\Documents\Anaconda\envs\mstrio\lib\site-packages\mstrio\utils\helper.py:260, in response_handler(response, msg, throw_error, verbose, whitelist)
    254             logger.error(
    255                 f'{msg}\n'
    256                 f'I-Server Error {server_code}, {server_msg}\n'
    257                 f'Ticket ID: {ticket_id}'
    258             )
    259         if throw_error:
--> 260             raise IServerError(
    261                 message=(
    262                     f"{server_msg}; code: '{server_code}', ticket_id: '{ticket_id}'"
    263                 ),
    264                 http_code=response.status_code,
    265             )
    266 except JSONDecodeError:
    267     logger.debug(f"Response body: {response.text}")

IServerError: The object does not exist in the metadata.; code: 'ERR004', ticket_id: '30407a50d12645eba0cd313314e29a74'
kkadu commented 1 year ago

I am not sure if it is related to the load balance for the rest api. We have a clustered environment managed by load balancer, so I believe the session information is passed along when we connect. I also tried to do it via "Get Cube Definition API" - {{baseUrl}}/api/v2/cubes/:cubeId but getting the same error.

urszulajaczewska commented 1 year ago

Hi @kkadu, this might be related to the load balancer. Could you try using connection.select_project before cube creation?

kkadu commented 1 year ago

Yes, we do that already. Here is our script -

conn.select_project(project_id=mstr_project_id)
dataset = SuperCube(conn, name=cube)
dataset.add_table(name=cube, data_frame=df, update_policy=update_policy, to_attribute=header, to_metric=[])
dataset.create()

The problem I am trying to understand is, when the cube is actually getting created successfully, why are we getting an error while fetching its definition \super_cube.py:475 here.

urszulajaczewska commented 1 year ago

@kkadu Please contact Support to log a case for this issue as this might be related to metadata or cluster configuration.

mgorskiMicroStrategy commented 10 months ago

@kkadu closing the issue at this moment as not reproducible if more info about issue will be gathered we can re-open this issue. cc: @urszulajaczewska