/// <summary> /// Generate RFA (or take it from cache). /// </summary> public async Task GenerateRfaAsync(string projectName, string hash) { _logger.LogInformation($"Generating RFA for hash {hash}"); ProjectStorage storage = await _userResolver.GetProjectStorageAsync(projectName); Project project = storage.Project; //// ********************************************* //// temporary fail ********************************************* //_logger.LogError($"Failed to generate SAT file"); //throw new FdaProcessingException($"Failed to generate SAT file", "https://localhost:5000/#"); //// ********************************************* var ossNameProvider = project.OssNameProvider(hash); var bucket = await _userResolver.GetBucketAsync(); // check if RFA file is already generated try { // TODO: this might be ineffective as some "get details" API call await bucket.CreateSignedUrlAsync(ossNameProvider.Rfa); return; } catch (ApiException e) when(e.ErrorCode == StatusCodes.Status404NotFound) { // the file does not exist, so just swallow } // OK, nothing in cache - generate it now var inputDocUrl = await bucket.CreateSignedUrlAsync(ossNameProvider.GetCurrentModel(storage.IsAssembly)); ProcessingArgs satData = await _arranger.ForSatAsync(inputDocUrl, storage.Metadata.TLA); ProcessingArgs rfaData = await _arranger.ForRfaAsync(satData.SatUrl); ProcessingResult result = await _fdaClient.GenerateRfa(satData, rfaData); if (!result.Success) { _logger.LogError($"{result.ErrorMessage} for project {project.Name} and hash {hash}"); throw new FdaProcessingException($"{result.ErrorMessage} for project {project.Name} and hash {hash}", result.ReportUrl); } await _arranger.MoveRfaAsync(project, hash); }
/// <summary> /// Generate RFA (or take it from cache). /// </summary> public async Task <FdaStatsDTO> GenerateRfaAsync(string projectName, string hash) { _logger.LogInformation($"Generating RFA for hash {hash}"); ProjectStorage storage = await _userResolver.GetProjectStorageAsync(projectName); Project project = storage.Project; //// ********************************************* //// temporary fail ********************************************* //_logger.LogError($"Failed to generate SAT file"); //throw new FdaProcessingException($"Failed to generate SAT file", "https://localhost:5000/#"); //// ********************************************* var ossNames = project.OssNameProvider(hash); var bucket = await _userResolver.GetBucketAsync(); // check if RFA file is already generated if (await bucket.ObjectExistsAsync(ossNames.Rfa)) { var stats = await bucket.DeserializeAsync <Statistics[]>(ossNames.StatsRFA); return(FdaStatsDTO.CreditsOnly(stats)); } // OK, nothing in cache - generate it now var inputDocUrl = await bucket.CreateSignedUrlAsync(ossNames.GetCurrentModel(storage.IsAssembly)); ProcessingArgs satData = await _arranger.ForSatAsync(inputDocUrl, storage.Metadata.TLA); ProcessingArgs rfaData = await _arranger.ForRfaAsync(satData.SatUrl); ProcessingResult result = await _fdaClient.GenerateRfa(satData, rfaData); if (!result.Success) { _logger.LogError($"{result.ErrorMessage} for project {project.Name} and hash {hash}"); throw new FdaProcessingException($"{result.ErrorMessage} for project {project.Name} and hash {hash}", result.ReportUrl); } await _arranger.MoveRfaAsync(project, hash); await bucket.UploadAsJsonAsync(ossNames.StatsRFA, result.Stats); return(FdaStatsDTO.All(result.Stats)); }