Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build options is an arbitrary json object rather than a string #183

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Serval.Client/Client.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,8 @@ public partial interface ITranslationEnginesClient
/// <br/>you may flag a subset of books for pretranslation by including their [abbreviations](https://github.com/sillsdev/libpalaso/blob/master/SIL.Scripture/Canon.cs)
/// <br/>in the textIds parameter. If the engine does not support pretranslation, these fields have no effect.
/// <br/>
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON string.
/// <br/>A typical use case would be to set `"options"` to `"{\"max_steps\":10}"` in order to configure the maximum
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// <br/>A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes.
/// </remarks>
/// <param name="id">The translation engine id</param>
Expand Down Expand Up @@ -2918,8 +2918,8 @@ public string BaseUrl
/// <br/>you may flag a subset of books for pretranslation by including their [abbreviations](https://github.com/sillsdev/libpalaso/blob/master/SIL.Scripture/Canon.cs)
/// <br/>in the textIds parameter. If the engine does not support pretranslation, these fields have no effect.
/// <br/>
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON string.
/// <br/>A typical use case would be to set `"options"` to `"{\"max_steps\":10}"` in order to configure the maximum
/// <br/>The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// <br/>A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// <br/>number of training iterations in order to reduce turnaround time for testing purposes.
/// </remarks>
/// <param name="id">The translation engine id</param>
Expand Down Expand Up @@ -4457,7 +4457,7 @@ public partial class TranslationBuild
public System.DateTimeOffset? DateFinished { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("options", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? Options { get; set; } = default!;
public object? Options { get; set; } = default!;

}

Expand Down Expand Up @@ -4504,7 +4504,7 @@ public partial class TranslationBuildConfig
public System.Collections.Generic.IList<PretranslateCorpusConfig>? Pretranslate { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("options", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? Options { get; set; } = default!;
public object? Options { get; set; } = default!;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ public class TranslationBuildConfigDto
public string? Name { get; set; }
public IList<PretranslateCorpusConfigDto>? Pretranslate { get; set; }

public string? Options { get; set; }
/// <example>
/// {
/// "property" : "value"
/// }
/// </example>
public object? Options { get; set; }
}
8 changes: 7 additions & 1 deletion src/Serval.Translation/Contracts/TranslationBuildDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ public class TranslationBuildDto
/// </summary>
public JobState State { get; set; }
public DateTime? DateFinished { get; set; }
public string? Options { get; set; }

/// <example>
/// {
/// "property" : "value"
/// }
/// </example>
public object? Options { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ CancellationToken cancellationToken
/// you may flag a subset of books for pretranslation by including their [abbreviations](https://github.com/sillsdev/libpalaso/blob/master/SIL.Scripture/Canon.cs)
/// in the textIds parameter. If the engine does not support pretranslation, these fields have no effect.
///
/// The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON string.
/// A typical use case would be to set `"options"` to `"{\"max_steps\":10}"` in order to configure the maximum
/// The `"options"` parameter of the build config provides the ability to pass build configuration parameters as a JSON object.
/// A typical use case would be to set `"options"` to `{"max_steps":10}` in order to configure the maximum
/// number of training iterations in order to reduce turnaround time for testing purposes.
/// </remarks>
/// <param name="id">The translation engine id</param>
Expand Down Expand Up @@ -1020,7 +1020,7 @@ private static Build Map(Engine engine, TranslationBuildConfigDto source)
var jsonSerializerOptions = new JsonSerializerOptions();
jsonSerializerOptions.Converters.Add(new ObjectToInferredTypesConverter());
build.Options = JsonSerializer.Deserialize<IDictionary<string, object>>(
source.Options ?? "{}",
source.Options?.ToString() ?? "{}",
jsonSerializerOptions
);
}
Expand Down Expand Up @@ -1070,7 +1070,7 @@ private TranslationBuildDto Map(Build source)
QueueDepth = source.QueueDepth,
State = source.State,
DateFinished = source.DateFinished,
Options = JsonSerializer.Serialize(source.Options)
Options = source.Options
};
}

Expand Down