Esempio n. 1
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.WorkspaceName = this.WorkspaceObject.Name;
            }

            if (!this.IsParameterBound(c => c.Name))
            {
                string path = this.TryResolvePath(DefinitionFile);
                this.Name = Path.GetFileNameWithoutExtension(path);
            }

            if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.SettingSynapseNotebook, this.Name, this.WorkspaceName)))
            {
                string           rawJsonContent   = SynapseAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(DefinitionFile));
                Notebook         notebook         = JsonConvert.DeserializeObject <Notebook>(rawJsonContent);
                NotebookResource notebookResource = new NotebookResource(this.Name, notebook);

                if (this.IsParameterBound(c => c.SparkPoolName))
                {
                    NotebookMetadata metadata = notebookResource.Properties.Metadata;
                    var options = new ComputeOptions();

                    string suffix        = DefaultContext.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix);
                    string endpoint      = "https://" + this.WorkspaceName + "." + suffix;
                    var    sparkPoolInfo = SynapseAnalyticsClient.GetBigDataPool(SparkPoolName);

                    options["auth"] = new ComputeOptions
                    {
                        ["type"]         = "AAD",
                        ["authResource"] = DefaultContext.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointResourceId)
                    };
                    options["cores"]        = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Cores;
                    options["memory"]       = SynapseConstants.ComputeNodeSizes[this.ExecutorSize].Memory;
                    options["nodeCount"]    = this.ExecutorCount;
                    options["endpoint"]     = endpoint + "/livyApi/versions/" + SynapseConstants.SparkServiceEndpointApiVersion + "/sparkPools/" + this.SparkPoolName;
                    options["extraHeader"]  = new ComputeOptions();
                    options["id"]           = sparkPoolInfo.Id;
                    options["name"]         = this.SparkPoolName;
                    options["sparkVersion"] = sparkPoolInfo.SparkVersion;
                    options["type"]         = "Spark";
                    metadata.AdditionalProperties.Add("a365ComputeOptions", options);

                    notebookResource.Properties.BigDataPool       = new BigDataPoolReference(BigDataPoolReferenceType.BigDataPoolReference, this.SparkPoolName);
                    notebookResource.Properties.SessionProperties = new NotebookSessionProperties(options["memory"] + "g", (int)options["cores"], options["memory"] + "g", (int)options["cores"], (int)options["nodeCount"]);
                }

                if (this.IsParameterBound(c => c.FolderPath))
                {
                    NotebookFolder folder = new NotebookFolder();
                    folder.Name = this.FolderPath;
                    notebookResource.Properties.Folder = folder;
                }

                WriteObject(new PSNotebookResource(SynapseAnalyticsClient.CreateOrUpdateNotebook(this.Name, notebookResource), this.WorkspaceName));
            }
        }
Esempio n. 2
0
        public NotebookMetadata ToSdkObject()
        {
            var metadata = new NotebookMetadata()
            {
                Kernelspec   = this.Kernelspec?.ToSdkObject(),
                LanguageInfo = this.LanguageInfo?.ToSdkObject()
            };

            this.AdditionalProperties?.ForEach(item => metadata.Add(item.Key, item.Value));
            return(metadata);
        }
Esempio n. 3
0
        public PSNotebookMetadata(NotebookMetadata notebookMetadata)
        {
            this.Kernelspec   = new PSNotebookKernelSpec(notebookMetadata?.Kernelspec);
            this.LanguageInfo = new PSNotebookLanguageInfo(notebookMetadata?.LanguageInfo);
            var propertiesEnum = notebookMetadata?.GetEnumerator();

            if (propertiesEnum != null)
            {
                this.AdditionalProperties = new Dictionary <string, object>();
                while (propertiesEnum.MoveNext())
                {
                    this.AdditionalProperties.Add(propertiesEnum.Current);
                }
            }
        }
 public PSNotebookMetadata(NotebookMetadata notebookMetadata)
 {
     this.Kernelspec           = new PSNotebookKernelSpec(notebookMetadata?.Kernelspec);
     this.LanguageInfo         = new PSNotebookLanguageInfo(notebookMetadata?.LanguageInfo);
     this.AdditionalProperties = notebookMetadata?.AdditionalProperties;
 }