How to access a Data asset via R function in Azure Notebook
When I tried to access a data asset from R function in Azure Notebook, I failed. But I can access the same data asset in the same Azure Notebook with a python function. My intention is to initialize a mixed Python-R programming script.
Details: Conda environment Python 3.8 - AzureML. All the packaged mentioned below were installed.
## import rpy2 to use R functions
from rpy2.robjects.packages import importr
## import R package
dt = importr('data.table')
## import Azure packages
from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
from azure.ai.ml.entities import Data
from azure.ai.ml.constants import AssetTypes
import azureml.fsspec
credential = DefaultAzureCredential()
ml_client = MLClient(
credential=credential,
subscription_id="*****************",
resource_group_name="*************",
workspace_name="*********",
)
## data asset info
data_asset = ml_client.data.get(name="*******", version=**)
print(f"Data asset URI: {data_asset.path}")
When I tried to use a function fread
from R-data.table, one error message appeared:
df = dt.fread(data_asset.path)
df.head()
Error Message: RRuntimeError: Error: File 'azureml://subscriptions/....../datastores/....../paths/source/...csv' does not exist or is non-readable.
But when I used a function from Python in the same Azure notebook, I can read the same '.csv' file.
df = pd.read_csv(data_asset.path)
df.head()
Apparently, the data asset is accessible from this Azure notebook. Why cannot I read it through R function? I guess the problem is about the Runtime and Credential, because A "RRuntime" was created for R function in this Python Runtime. If it is the problem, does that mean I should pass the Credential to the "RRuntime"? could someone help me out?
Thank you in advance!