Esempio n. 1
0
        /// <summary>
        /// ステータスを更新して、出力モデルに変換する
        /// </summary>
        private async Task <InferenceIndexOutputModel> GetUpdatedIndexOutputModelAsync(InferenceHistory history)
        {
            var model = new InferenceIndexOutputModel(history);

            var status = history.GetStatus();

            if (status.Exist())
            {
                //推論がまだ進行中の場合、情報を更新する
                var newStatus = await clusterManagementLogic.GetContainerStatusAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false);

                if (status.Key != newStatus.Key)
                {
                    //更新があったので、変更処理
                    await inferenceHistoryRepository.UpdateStatusAsync(history.Id, newStatus, false);

                    unitOfWork.Commit();

                    model.Status = newStatus.Name;
                }
            }

            // storageへの出力値があれば取得し、modelに格納
            var outputFileName = "value.txt";   //値を読み込むファイル名
            var outputPath     = history.Id + "/" + outputFileName;
            var content        = await storageLogic.GetFileContentAsync(ResourceType.InferenceContainerOutputFiles, outputPath, outputFileName, true);

            if (content != null)
            {
                model.OutputValue = content;
            }
            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// ノートブックのトークンを取得する
        /// </summary>
        /// <param name="historyId">ノートブック履歴ID</param>
        /// <returns></returns>
        private async Task <string> GetNotebookTokenAsync(long historyId)
        {
            //notebook起動時のログをストレージから取得し、token情報を抜き出す。
            var outputFileName = ".notebook.log";   //値を読み込むファイル名
            var outputPath     = historyId + "/" + outputFileName;
            var content        = await storageLogic.GetFileContentAsync(ResourceType.NotebookContainerAttachedFiles, outputPath, outputFileName, true);

            if (content != null)
            {
                // ?token=...という文字列を抜き出す
                var token = Regex.Match(content, @"\?token=.*").Value;
                return(token);
            }
            return("");
        }
Esempio n. 3
0
        /// <summary>
        /// ノートブックのエンドポイントURLを取得する
        /// </summary>
        /// <param name="historyId">ノートブック履歴ID</param>
        /// <param name="endPoints">エンドポイント</param>
        /// <returns></returns>
        private async Task <string> GetNotebookEndpointUrlAsync(long historyId, IEnumerable <EndPointInfo> endPoints)
        {
            //notebook起動時のログをストレージから取得し、token情報を抜き出す。
            var outputFileName = ".notebook.log";   //値を読み込むファイル名
            var outputPath     = historyId + "/" + outputFileName;
            var content        = await storageLogic.GetFileContentAsync(ResourceType.NotebookContainerAttachedFiles, outputPath, outputFileName, true);

            if (content != null)
            {
                // ?token=...という文字列を抜き出す
                var token = Regex.Match(content, @"\?token=.*").Value;

                // ノードのendpoint情報を取得し、tokenと繋ぎ合わせてmodelに設定
                var nodeEndPoint = endPoints.Where(name => name.Key == "notebook").FirstOrDefault();
                if (nodeEndPoint != null)
                {
                    return("http://" + nodeEndPoint.Url + token);
                }
            }
            return("");
        }
        /// <summary>
        /// ノートブックのエンドポイントURLを取得する
        /// </summary>
        /// <param name="historyId">ノートブック履歴ID</param>
        /// <param name="endPoints">エンドポイント</param>
        /// <param name="webEndpoint">Webエンドポイント</param>
        /// <returns></returns>
        private async Task <string> GetNotebookEndpointUrlAsync(long historyId, IEnumerable <EndPointInfo> endPoints, string webEndpoint = null)
        {
            //notebook起動時のログをストレージから取得し、token情報を抜き出す。
            var outputFileName = ".notebook.log";   //値を読み込むファイル名
            var outputPath     = historyId + "/" + outputFileName;
            var content        = await storageLogic.GetFileContentAsync(ResourceType.NotebookContainerAttachedFiles, outputPath, outputFileName, true);

            if (content != null)
            {
                // ?token=...という文字列を抜き出す
                var token = Regex.Match(content, @"\?token=.*").Value;

                // ノードのendpoint情報を取得し、tokenと繋ぎ合わせてmodelに設定
                var nodeEndPoint = endPoints.Where(name => name.Key == "notebook").FirstOrDefault();
                if (nodeEndPoint != null)
                {
                    // リバプロなどでノードのホスト名ではなく、共通のエンドポイントを使える場合は、そちらを使用する
                    string host = string.IsNullOrEmpty(webEndpoint) ? nodeEndPoint.Host : webEndpoint;
                    return(new UriBuilder("http", host, (int)nodeEndPoint.Port).ToString() + token);
                }
            }
            return("");
        }