Skip to content

Commit

Permalink
feat(ml-cli): set filename instead of hardcoded filename
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Jul 24, 2023
1 parent 087fff4 commit 919791d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/MlCli/JobApiCall/ApiCallFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public async Task ApiCallFilesAsync(string fileName, string json, Callapi inputT
{
var httpClient = _httpClientFactory.CreateClient(inputTask.Id);

_logger.LogInformation($"Task Id : {inputTask.Id} - Processing {fileName}.json");
_logger.LogInformation("Task Id : {InputTaskId} - Processing {FileName}.json", inputTask.Id, fileName);

var httpResult = JsonConvert.DeserializeObject<Program.HttpResult>(json);

var correctStatusCode = 200;
if (httpResult.StatusCode != correctStatusCode)
{
_logger.LogError($"Task Id: {inputTask.Id} - Error: server didn't return 200 status code");
_logger.LogError("Task Id: {InputTaskId} - Error: server didn\'t return 200 status code", inputTask.Id);
return;
}

Expand Down Expand Up @@ -149,10 +149,7 @@ private async Task DownloadFilesAsync(HttpClient httpClient, string fileName, Fi

_fileLoader.CreateDirectory(outputPath);

await _fileLoader.WriteAllBytesOfFileAsync(filePath
,
imageBytes
);
await _fileLoader.WriteAllBytesOfFileAsync(filePath, imageBytes);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/MlCli/JobApiCall/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public static string GetTargetFileName(bool isDefaultTargetFileMode, string curr
}
else
{
_logger.LogWarning($"Task Id: {inputTask.Id} - Error : file {settingFile} not found");
_logger.LogWarning("Task Id: {InputTaskId} - Error : file {SettingFile} not found", inputTask.Id, settingFile);
}
}
}
Expand All @@ -254,7 +254,7 @@ public static string GetTargetFileName(bool isDefaultTargetFileMode, string curr
else
{
var streamContent = new StreamContent(_fileLoader.OpenRead(file));
requestContent.Add(streamContent, "file", $"filename{Path.GetExtension(file)}");
requestContent.Add(streamContent, "file", WebUtility.UrlEncode(fileName));
}

request.Content = requestContent;
Expand Down

0 comments on commit 919791d

Please sign in to comment.