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

[Bug]: AttributeError("'K8sHelper' object has no attribute 'v1api'") for DatastoreProfileAzureBlob/Docker Desktop #5292

Closed
2 tasks done
george0st opened this issue Mar 15, 2024 · 4 comments

Comments

@george0st
Copy link
Collaborator

george0st commented Mar 15, 2024

MLRun Version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of MLRun CE.

Reproducible Example

import mlrun
import mlrun.feature_store as fstore
from mlrun.datastore.targets import RedisNoSqlTarget,SQLTarget, CSVTarget, ParquetTarget
from mlrun.datastore.datastore_profile import DatastoreProfileAzureBlob
from mlrun.data_types.data_types import ValueType
import pandas as pd
import numpy
import sys
import os
import datetime
import random
import string


def azure_parquet_target(project):
    connection_str="DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net"
    acc_name = "jiststorage01"
    acc_key = "<add valid key>"

    profile = DatastoreProfileAzureBlob(name="aa2", connection_string=connection_str, account_name=acc_name, account_key=acc_key)
    project.register_datastore_profile(profile)

    return ParquetTarget(path="ds://aa2/jistcontainer01/tst/")

def azure(project_name):

    mlrun.set_env_from_file("mlrun-nonprod.env")
    project = mlrun.get_or_create_project(project_name, context='./', user_project=False)

    feature_name = "basic-party"
    feature_set = fstore.FeatureSet(feature_name, entities=[fstore.Entity("party-id", value_type=ValueType.INT64)],
                                    engine="storey")
    feature_set.add_feature(fstore.Feature(name="party-type"))
    feature_set.set_targets(targets=[azure_parquet_target(project)],
                            with_defaults=False)
    feature_set.save()
    data = {"party-id": [1, 2, 3],
            "party-type": ["a1", "b2", "c3"]}
    dataFrm = pd.DataFrame(data)
    fstore.ingest(feature_set, dataFrm, overwrite=False)


if __name__ == '__main__':
    azure("ab2")

Issue Description

See exception during the call project.register_datastore_profile(profile)

Traceback (most recent call last):
  File "C:\Python\test\.venv\lib\site-packages\mlrun\errors.py", line 93, in raise_for_status
    response.raise_for_status()
  File "C:\Python\test\.venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:8080/api/v1/projects/ab2/datastore-profiles

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python\test\.venv\lib\site-packages\mlrun\errors.py", line 104, in raise_for_status
    raise STATUS_ERRORS[status_code](error_message, response=response) from exc
mlrun.errors.MLRunInternalServerError: 500 Server Error: Internal Server Error for url: http://localhost:8080/api/v1/projects/ab2/datastore-profiles: details: AttributeError("'K8sHelper' object has no attribute 'v1api'")
python-BaseException

Expected Behavior

It will be possible to use DatastoreProfileAzureBlob in Docker Desktop (with OS Windows and WSL)

Installation OS

Windows

Installation Method

Docker

Python Version

3.9.10

MLRun Version

1.6.1

Additional Information

The address http://localhost:8080/api/v1/projects/ab2/ return relevant YAML content.

@george0st george0st changed the title [Bug]: AttributeError("'K8sHelper' object has no attribute 'v1api'") for DatastoreProfileAzureBlob [Bug]: AttributeError("'K8sHelper' object has no attribute 'v1api'") for DatastoreProfileAzureBlob/Docker Desktop Mar 15, 2024
@george0st
Copy link
Collaborator Author

george0st commented Mar 19, 2024

It seems as internal issue with old interface (or issue with build for docker desktop).

NOTE: Standart access to the Azure BlobStorage works correctly, see this code sample

    from azure.storage.blob import ContainerClient

    connection_string = "DefaultEndpointsProtocol=https;AccountName=jiststorage01;AccountKey=<valid key>;EndpointSuffix=core.windows.net"
    container = ContainerClient.from_connection_string(conn_str=connection_string, container_name="jistcontainer01")
    blob_list = container.list_blobs()
    for blob in blob_list:
        print(blob.name)

@assaf758
Copy link
Member

@george0st just to clarify - I understand you are running k8s inside a docker? If indeed the case, are you using an mlrun supported version of k8s?
Regarding datastore profiles - when referencing a profile locally / from the sdk (like it seems you do) you should register the profile with register_temporary_client_datastore_profile(). See datastore profiles for more info.

@george0st
Copy link
Collaborator Author

george0st commented Mar 20, 2024

Hi @assaf758, I used docker desktop with compose.yaml file (see the installation https://docs.mlrun.org/en/latest/install/local-docker.html#use-mlrun-with-your-own-client ). I will try to use register_temporary_client_datastore_profile thx.

@george0st
Copy link
Collaborator Author

george0st commented Mar 20, 2024

Hi @assaf758 , I used register_temporary_client_datastore_profile() and It works, many thx. I will close this issue.

image

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

2 participants