Skip to content

Commit

Permalink
upgrading aml nuget package (#3411)
Browse files Browse the repository at this point in the history
  • Loading branch information
achauhan-scc authored Oct 9, 2024
1 parent 5d2fa2a commit 67d9ae1
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 110 deletions.
12 changes: 6 additions & 6 deletions sdk/dotnet/AzureML-Samples-CSharp/Assets/Code/CodeOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class CodeOperations
/// <param name="version"></param>
/// <returns></returns>
// <GetOrCreateCodeVersionAsync>
public static async Task<CodeVersionResource> GetOrCreateCodeVersionAsync(
public static async Task<MachineLearningCodeVersionResource> GetOrCreateCodeVersionAsync(
ArmClient armClient,
ResourceGroupResource resourceGroup,
string workspaceName,
Expand All @@ -32,13 +32,13 @@ public static async Task<CodeVersionResource> GetOrCreateCodeVersionAsync(

string resourceId = $"{ws.Id}/codes/{codeName}";
var id = new ResourceIdentifier(resourceId);
CodeContainerResource codeContainerDataResource = armClient.GetCodeContainerResource(id);
MachineLearningCodeContainerResource codeContainerDataResource = armClient.GetMachineLearningCodeContainerResource(id);

CodeVersionProperties properties = new CodeVersionProperties { CodeUri = new Uri(codeUri) };
CodeVersionData data = new CodeVersionData(properties);
MachineLearningCodeVersionProperties properties = new MachineLearningCodeVersionProperties { CodeUri = new Uri(codeUri) };
MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(properties);

ArmOperation<CodeVersionResource> CodeVersionResourceOperation = await codeContainerDataResource.GetCodeVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
CodeVersionResource codeVersionResource = CodeVersionResourceOperation.Value;
ArmOperation<MachineLearningCodeVersionResource> CodeVersionResourceOperation = await codeContainerDataResource.GetMachineLearningCodeVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
MachineLearningCodeVersionResource codeVersionResource = CodeVersionResourceOperation.Value;
Console.WriteLine($"codeVersionResource {codeVersionResource.Data.Id} created.");

return codeVersionResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class ComponentOperations
/// <param name="version"></param>
/// <returns></returns>
// <GetOrCreateComponentVersionAsync>
public static async Task<ComponentVersionResource> GetOrCreateComponentVersionAsync(
public static async Task<MachineLearningComponentVersionResource> GetOrCreateComponentVersionAsync(
ArmClient armClient,
ResourceGroupResource resourceGroup,
string workspaceName,
Expand All @@ -34,7 +34,7 @@ public static async Task<ComponentVersionResource> GetOrCreateComponentVersionAs

string resourceId = $"{ws.Id}/components/{componentName}";
var id = new ResourceIdentifier(resourceId);
ComponentContainerResource componentContainerResource = armClient.GetComponentContainerResource(id);
MachineLearningComponentContainerResource componentContainerResource = armClient.GetMachineLearningComponentContainerResource(id);

JObject jsonObject = JObject.Parse(@"{
'$schema': 'https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json',
Expand Down Expand Up @@ -80,11 +80,11 @@ public static async Task<ComponentVersionResource> GetOrCreateComponentVersionAs
},
}");

ComponentVersionProperties properties = new ComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) };
ComponentVersionData data = new ComponentVersionData(properties);
MachineLearningComponentVersionProperties properties = new MachineLearningComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) };
MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(properties);

ArmOperation<ComponentVersionResource> componentVersionResourceOperation = await componentContainerResource.GetComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
ComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value;
ArmOperation<MachineLearningComponentVersionResource> componentVersionResourceOperation = await componentContainerResource.GetMachineLearningComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
MachineLearningComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value;
Console.WriteLine($"ComponentVersionResource {componentVersionResource.Id} created.");
return componentVersionResource;
}
Expand All @@ -102,7 +102,7 @@ public static async Task<ComponentVersionResource> GetOrCreateComponentVersionAs
/// <param name="version"></param>
/// <returns></returns>
// <GetOrCreateComponentVersion_Pipeline_Async>
public static async Task<ComponentVersionResource> GetOrCreateComponentVersion_Pipeline_Async(
public static async Task<MachineLearningComponentVersionResource> GetOrCreateComponentVersion_Pipeline_Async(
ArmClient armClient,
ResourceGroupResource resourceGroup,
string workspaceName,
Expand All @@ -116,7 +116,7 @@ public static async Task<ComponentVersionResource> GetOrCreateComponentVersion_P

string resourceId = $"{ws.Id}/components/{componentName}";
var id = new ResourceIdentifier(resourceId);
ComponentContainerResource componentContainerResource = armClient.GetComponentContainerResource(id);
MachineLearningComponentContainerResource componentContainerResource = armClient.GetMachineLearningComponentContainerResource(id);

JObject jsonObject = JObject.Parse(@"{
'$schema': 'https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json',
Expand Down Expand Up @@ -150,11 +150,11 @@ public static async Task<ComponentVersionResource> GetOrCreateComponentVersion_P
},
}");

ComponentVersionProperties properties = new ComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) };
ComponentVersionData data = new ComponentVersionData(properties);
MachineLearningComponentVersionProperties properties = new MachineLearningComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) };
MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(properties);

ArmOperation<ComponentVersionResource> componentVersionResourceOperation = await componentContainerResource.GetComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
ComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value;
ArmOperation<MachineLearningComponentVersionResource> componentVersionResourceOperation = await componentContainerResource.GetMachineLearningComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
MachineLearningComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value;
Console.WriteLine($"ComponentVersionResource {componentVersionResource.Id} created.");
return componentVersionResource;
}
Expand Down
46 changes: 23 additions & 23 deletions sdk/dotnet/AzureML-Samples-CSharp/Assets/Data/DataOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class DataOperations
/// <param name="version"></param>
/// <returns></returns>
// <GetOrCreateDataVersionAsync>
public static async Task<DataVersionBaseResource> GetOrCreateDataVersionAsync(
public static async Task<MachineLearningDataVersionResource> GetOrCreateDataVersionAsync(
ArmClient armClient,
ResourceGroupResource resourceGroup,
string workspaceName,
Expand All @@ -30,24 +30,24 @@ public static async Task<DataVersionBaseResource> GetOrCreateDataVersionAsync(
MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName);
string resourceId = $"{ws.Id}/data/{dataName}";
var id = new ResourceIdentifier(resourceId);
DataContainerResource dataContainerResource = armClient.GetDataContainerResource(id);
MachineLearningDataContainerResource dataContainerResource = armClient.GetMachineLearningDataContainerResource(id);

bool exists = await dataContainerResource.GetDataVersionBases().ExistsAsync(version);
bool exists = await dataContainerResource.GetMachineLearningDataVersions().ExistsAsync(version);


DataVersionBaseResource dataVersionBaseResource;
MachineLearningDataVersionResource dataVersionBaseResource;
if (exists)
{
Console.WriteLine($"DataVersionBaseResource {dataName} exists.");
dataVersionBaseResource = await dataContainerResource.GetDataVersionBases().GetAsync(version);
dataVersionBaseResource = await dataContainerResource.GetMachineLearningDataVersions().GetAsync(version);
Console.WriteLine($"DataVersionBaseResource details: {dataVersionBaseResource.Data.Id}");
}
else
{

Console.WriteLine($"Creating DataVersionBaseResource {dataName}");
// UriFolderDataVersion, or UriFileDataVersion or MLTableData
DataVersionBaseProperties properties = new UriFileDataVersion(new Uri("https://pipelinedata.blob.core.windows.net/sampledata/nytaxi/"))
MachineLearningDataVersionProperties properties = new MachineLearningUriFileDataVersion(new Uri("https://pipelinedata.blob.core.windows.net/sampledata/nytaxi/"))
{
Description = "Test description",
Tags = new Dictionary<string, string> { { "tag-name-1", "tag-value-1" } },
Expand All @@ -56,9 +56,9 @@ public static async Task<DataVersionBaseResource> GetOrCreateDataVersionAsync(
IsArchived = false,
};

DataVersionBaseData data = new DataVersionBaseData(properties);
MachineLearningDataVersionData data = new MachineLearningDataVersionData(properties);

ArmOperation<DataVersionBaseResource> dataVersionBaseResourceOperation = await dataContainerResource.GetDataVersionBases().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
ArmOperation<MachineLearningDataVersionResource> dataVersionBaseResourceOperation = await dataContainerResource.GetMachineLearningDataVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
dataVersionBaseResource = dataVersionBaseResourceOperation.Value;
Console.WriteLine($"DataVersionBaseResource {dataVersionBaseResource.Data.Id} created.");
}
Expand All @@ -77,9 +77,9 @@ public static async Task ListDataAsync(
{
Console.WriteLine("Listing Datasets in the workspace...");
MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName);
DataContainerCollection dataContainerCollection = ws.GetDataContainers();
AsyncPageable<DataContainerResource> response = dataContainerCollection.GetAllAsync();
await foreach (DataContainerResource dataContainerResource in response)
MachineLearningDataContainerCollection dataContainerCollection = ws.GetMachineLearningDataContainers();
AsyncPageable<MachineLearningDataContainerResource> response = dataContainerCollection.GetAllAsync();
await foreach (MachineLearningDataContainerResource dataContainerResource in response)
{
Console.WriteLine(dataContainerResource.Data.Name);
}
Expand All @@ -99,34 +99,34 @@ public static async Task ListDatastoreAsync(
{
Console.WriteLine("Listing Datastore in the workspace...");
MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName);
DatastoreCollection datastoreCollection = ws.GetDatastores();
AsyncPageable<DatastoreResource> response = datastoreCollection.GetAllAsync();
await foreach (DatastoreResource datastoreResource in response)
MachineLearningDatastoreCollection datastoreCollection = ws.GetMachineLearningDatastores();
AsyncPageable<MachineLearningDatastoreResource> response = datastoreCollection.GetAllAsync();
await foreach (MachineLearningDatastoreResource datastoreResource in response)
{
DatastoreProperties properties = datastoreResource.Data.Properties;
MachineLearningDatastoreProperties properties = datastoreResource.Data.Properties;
switch (properties)
{
case AzureFileDatastore:
AzureFileDatastore azureFileDatastore = (AzureFileDatastore)datastoreResource.Data.Properties;
case MachineLearningAzureFileDatastore:
MachineLearningAzureFileDatastore azureFileDatastore = (MachineLearningAzureFileDatastore)datastoreResource.Data.Properties;
Console.WriteLine($"AccountName {azureFileDatastore.AccountName}");
Console.WriteLine($"FileShareName {azureFileDatastore.FileShareName}");
Console.WriteLine($"Endpoint {azureFileDatastore.Endpoint}");
break;

case AzureBlobDatastore:
AzureBlobDatastore azureBlobDatastore = (AzureBlobDatastore)datastoreResource.Data.Properties;
case MachineLearningAzureBlobDatastore:
MachineLearningAzureBlobDatastore azureBlobDatastore = (MachineLearningAzureBlobDatastore)datastoreResource.Data.Properties;
Console.WriteLine($"AccountName {azureBlobDatastore.AccountName}");
Console.WriteLine($"ContainerName {azureBlobDatastore.ContainerName}");
Console.WriteLine($"Endpoint {azureBlobDatastore.Endpoint}");
break;

case AzureDataLakeGen1Datastore:
AzureDataLakeGen1Datastore azureDataLakeGen1Datastore = (AzureDataLakeGen1Datastore)datastoreResource.Data.Properties;
case MachineLearningAzureDataLakeGen1Datastore:
MachineLearningAzureDataLakeGen1Datastore azureDataLakeGen1Datastore = (MachineLearningAzureDataLakeGen1Datastore)datastoreResource.Data.Properties;
Console.WriteLine($"StoreName {azureDataLakeGen1Datastore.StoreName}");
break;

case AzureDataLakeGen2Datastore:
AzureDataLakeGen2Datastore azureDataLakeGen2Datastore = (AzureDataLakeGen2Datastore)datastoreResource.Data.Properties;
case MachineLearningAzureDataLakeGen2Datastore:
MachineLearningAzureDataLakeGen2Datastore azureDataLakeGen2Datastore = (MachineLearningAzureDataLakeGen2Datastore)datastoreResource.Data.Properties;
Console.WriteLine($"AccountName {azureDataLakeGen2Datastore.AccountName}");
Console.WriteLine($"Filesystem {azureDataLakeGen2Datastore.Filesystem}");
Console.WriteLine($"Endpoint {azureDataLakeGen2Datastore.Endpoint}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class EnvironmentOperations
/// <param name="version"></param>
/// <returns></returns>
// <GetOrCreateEnvironmentSpecificationVersionAsync>
public static async Task<EnvironmentVersionResource> GetOrCreateEnvironmentVersionAsync(
public static async Task<MachineLearningEnvironmentVersionResource> GetOrCreateEnvironmentVersionAsync(
ArmClient armClient,
ResourceGroupResource resourceGroup,
string workspaceName,
Expand All @@ -32,7 +32,7 @@ public static async Task<EnvironmentVersionResource> GetOrCreateEnvironmentVersi

string resourceId = $"{ws.Id}/environments/{environmentName}";
var id = new ResourceIdentifier(resourceId);
EnvironmentContainerResource environmentContainerResource = armClient.GetEnvironmentContainerResource(id);
MachineLearningEnvironmentContainerResource environmentContainerResource = armClient.GetMachineLearningEnvironmentContainerResource(id);

var condaDependences = new JObject();
condaDependences["channels"] = new JArray() { "conda-forge" };
Expand Down Expand Up @@ -60,20 +60,20 @@ public static async Task<EnvironmentVersionResource> GetOrCreateEnvironmentVersi
condaDependences["dependencies"] = dependencies;
Console.WriteLine($"condaDependences: {condaDependences}");

EnvironmentVersionProperties properties = new EnvironmentVersionProperties
MachineLearningEnvironmentVersionProperties properties = new MachineLearningEnvironmentVersionProperties
{
Description = "Test",
CondaFile = condaDependences.ToString(),
Tags = { { "key1", "value1" }, { "key2", "value2" } },
OSType = OperatingSystemType.Linux,
OSType = MachineLearningOperatingSystemType.Linux,
IsAnonymous = false,
Image = "mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04",
};

EnvironmentVersionData data = new EnvironmentVersionData(properties);
MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(properties);

ArmOperation<EnvironmentVersionResource> environmentVersionResourceOperation = await environmentContainerResource.GetEnvironmentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
EnvironmentVersionResource environmentVersionResource = environmentVersionResourceOperation.Value;
ArmOperation<MachineLearningEnvironmentVersionResource> environmentVersionResourceOperation = await environmentContainerResource.GetMachineLearningEnvironmentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data);
MachineLearningEnvironmentVersionResource environmentVersionResource = environmentVersionResourceOperation.Value;
Console.WriteLine($"EnvironmentVersionResource {environmentVersionResource.Data.Id} created.");

return environmentVersionResource;
Expand Down
Loading

0 comments on commit 67d9ae1

Please sign in to comment.