From 43edf4676309c69cb3647ab8a8bf7cf4442b601e Mon Sep 17 00:00:00 2001 From: MingboPeng Date: Fri, 10 Nov 2023 22:36:55 +0800 Subject: [PATCH] fix(JobPathArgument): improve ToUserFriendlyString() --- .../ManuallyAdded/Model/JobPathArgument.cs | 20 ++++++++++++++++--- src/PollinationSDK/Wrapper/JobRunner.cs | 2 +- .../Wrapper/LocalRunArguments.cs | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/PollinationSDK/ManuallyAdded/Model/JobPathArgument.cs b/src/PollinationSDK/ManuallyAdded/Model/JobPathArgument.cs index 90e33df1..fe8f84b0 100644 --- a/src/PollinationSDK/ManuallyAdded/Model/JobPathArgument.cs +++ b/src/PollinationSDK/ManuallyAdded/Model/JobPathArgument.cs @@ -59,12 +59,26 @@ public string CloudProjectSlug() return null; } - public string ToUserFriendlyString() + public string ToUserFriendlyString(bool withProjectSlug) { var uploaded = this.IsAssetUploaded(); - var hint = uploaded ? "CLOUD" : "PATH"; + var p = (this.Source.Obj as ProjectFolder)?.Path; - p = uploaded ? p : System.IO.Path.GetFileName(p); + var hint = "PATH"; + if (uploaded) + { + hint = "CLOUD"; + if (withProjectSlug) + { + var slug = this.CloudProjectSlug(); + hint = string.IsNullOrEmpty(slug) ? hint : $"{hint}:{slug}"; + } + } + else + { + p = System.IO.Path.GetFileName(p); + } + return $"#{this.Name}:${hint}/{p}"; } diff --git a/src/PollinationSDK/Wrapper/JobRunner.cs b/src/PollinationSDK/Wrapper/JobRunner.cs index 82f66dfe..36833536 100644 --- a/src/PollinationSDK/Wrapper/JobRunner.cs +++ b/src/PollinationSDK/Wrapper/JobRunner.cs @@ -60,7 +60,7 @@ public static async Task UploadJobAssetsAsync( { // check if all cloud path artifacts are within the same project - var invalidCloudAssets = job.Arguments.SelectMany(_ => _.OfType()).Where(_ => _.IsAssetUploaded() && _.CloudProjectSlug() != project.Slug).Select(_=> $"{_.ToUserFriendlyString()}@{_.CloudProjectSlug()}").Distinct(); + var invalidCloudAssets = job.Arguments.SelectMany(_ => _.OfType()).Where(_ => _.IsAssetUploaded() && _.CloudProjectSlug() != project.Slug).Select(_=> $"{_.ToUserFriendlyString(true)}").Distinct(); if (invalidCloudAssets.Any()) { var error = $"Following cloud assets cannot be uploaded to project {project.Slug}:\n\n{string.Join(Environment.NewLine, invalidCloudAssets)}"; diff --git a/src/PollinationSDK/Wrapper/LocalRunArguments.cs b/src/PollinationSDK/Wrapper/LocalRunArguments.cs index a02e618e..3bba5437 100644 --- a/src/PollinationSDK/Wrapper/LocalRunArguments.cs +++ b/src/PollinationSDK/Wrapper/LocalRunArguments.cs @@ -16,7 +16,7 @@ public class LocalRunArguments public LocalRunArguments(List> arguments) { // check if there are any cloud path artifacts - var invalidCloudAssets = arguments.OfType().Where(_ => _.IsAssetUploaded()).Select(_ => $"{_.ToUserFriendlyString()}@{_.CloudProjectSlug()}").Distinct(); + var invalidCloudAssets = arguments.OfType().Where(_ => _.IsAssetUploaded()).Select(_ => $"{_.ToUserFriendlyString(true)}").Distinct(); if (invalidCloudAssets.Any()) { var error = $"Cannot run a local study with cloud assets:\n\n{string.Join(Environment.NewLine, invalidCloudAssets)}";