Skip to content

Commit 1558943

Browse files
authored
Implement backend parameter internal_path_prefix (#251)
1 parent 3df896d commit 1558943

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Tes/Models/TesResources.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public partial class TesResources : IEquatable<TesResources>
3030
public TesResources()
3131
=> NewtonsoftJsonSafeInit.SetDefaultSettings();
3232

33-
public enum SupportedBackendParameters { vm_size, workflow_execution_identity };
33+
public enum SupportedBackendParameters { internal_path_prefix, vm_size, workflow_execution_identity };
3434

3535
/// <summary>
3636
/// Requested number of CPUs

src/TesApi.Web/BatchScheduler.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,11 @@ public void ClearBatchLogState()
415415
private static string GetCromwellExecutionDirectoryPath(TesTask task)
416416
=> GetParentPath(task.Inputs?.FirstOrDefault(IsCromwellCommandScript)?.Path.TrimStart('/'));
417417

418-
private static string GetStorageUploadPath(TesTask task, string storageAccountName)
418+
private string GetStorageUploadPath(TesTask task)
419419
{
420-
return $"{storageAccountName}/{TesExecutionsPathPrefix.TrimStart('/')}/{task.Id}";
420+
return task.Resources?.ContainsBackendParameterValue(TesResources.SupportedBackendParameters.internal_path_prefix) ?? false
421+
? $"{defaultStorageAccountName}/{task.Resources.GetBackendParameterValue(TesResources.SupportedBackendParameters.internal_path_prefix).Trim('/')}"
422+
: $"{defaultStorageAccountName}{TesExecutionsPathPrefix}/{task.Id}";
421423
}
422424

423425
/// <summary>
@@ -971,7 +973,7 @@ private async Task<CloudTask> ConvertTesTaskToBatchTaskAsync(string taskId, TesT
971973
// }
972974
//}
973975

974-
var storageUploadPath = GetStorageUploadPath(task, defaultStorageAccountName);
976+
var storageUploadPath = GetStorageUploadPath(task);
975977
var metricsName = "metrics.txt";
976978
var metricsPath = $"/{storageUploadPath}/{metricsName}";
977979
var metricsUrl = new Uri(await storageAccessProvider.MapLocalPathToSasUrlAsync(metricsPath, cancellationToken, getContainerSas: true));
@@ -1235,7 +1237,7 @@ private async Task<TesInput> GetTesInputFileUrlAsync(TesInput inputFile, TesTask
12351237

12361238
if (inputFile.Content is not null || IsCromwellCommandScript(inputFile))
12371239
{
1238-
var storageFileName = $"/{GetStorageUploadPath(task, defaultStorageAccountName)}/{Guid.NewGuid()}";
1240+
var storageFileName = $"/{GetStorageUploadPath(task)}/{Guid.NewGuid()}";
12391241
inputFileUrl = await storageAccessProvider.MapLocalPathToSasUrlAsync(storageFileName, cancellationToken);
12401242

12411243
var content = inputFile.Content ?? await storageAccessProvider.DownloadBlobAsync(inputFile.Url, cancellationToken);
@@ -1245,7 +1247,7 @@ private async Task<TesInput> GetTesInputFileUrlAsync(TesInput inputFile, TesTask
12451247
}
12461248
else if (TryGetCromwellTmpFilePath(inputFile.Url, out var localPath))
12471249
{
1248-
var storageFileName = $"/{GetStorageUploadPath(task, defaultStorageAccountName)}/{Guid.NewGuid()}";
1250+
var storageFileName = $"/{GetStorageUploadPath(task)}/{Guid.NewGuid()}";
12491251
inputFileUrl = await storageAccessProvider.MapLocalPathToSasUrlAsync(storageFileName, cancellationToken);
12501252
await storageAccessProvider.UploadBlobFromFileAsync(storageFileName, localPath, cancellationToken);
12511253
}
@@ -1770,7 +1772,7 @@ static bool TryGetValueAsDouble(Dictionary<string, string> dict, string key, out
17701772
cromwellRcCode = temp;
17711773
}
17721774

1773-
var metricsContent = await storageAccessProvider.DownloadBlobAsync($"/{GetStorageUploadPath(tesTask, defaultStorageAccountName)}/metrics.txt", cancellationToken);
1775+
var metricsContent = await storageAccessProvider.DownloadBlobAsync($"/{GetStorageUploadPath(tesTask)}/metrics.txt", cancellationToken);
17741776

17751777
if (metricsContent is not null)
17761778
{

0 commit comments

Comments
 (0)