From ad9d57c7a425b26ca5f49d6af77363ff117b60ef Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 26 Jan 2024 11:58:00 -0500 Subject: [PATCH] com.rest.huggingface 1.0.0-preview.15 (#14) --- .github/workflows/upm-subtree-split.yml | 18 +---- HuggingFace/.editorconfig | 81 ++++++++++--------- .../Runtime/Hub/HubEndpoint.cs | 10 +-- .../Runtime/HuggingFaceClient.cs | 16 ++-- .../AudioToAudio/AudioToAudioResponse.cs | 2 +- .../TextToSpeech/TextToSpeechResponse.cs | 2 +- .../ImageSegmentationResponse.cs | 2 +- .../ImageToImage/ImageToImageResponse.cs | 2 +- .../Runtime/Inference/InferenceEndpoint.cs | 4 +- .../TextToImage/TextToImageB64Response.cs | 2 +- .../TextToImage/TextToImageBinaryResponse.cs | 2 +- .../Tests/AbstractTestFixture.cs | 6 +- .../com.rest.huggingface/package.json | 8 +- HuggingFace/Packages/manifest.json | 4 +- .../ProjectSettings/ProjectVersion.txt | 4 +- 15 files changed, 77 insertions(+), 86 deletions(-) diff --git a/.github/workflows/upm-subtree-split.yml b/.github/workflows/upm-subtree-split.yml index 924eaba..77b33a1 100644 --- a/.github/workflows/upm-subtree-split.yml +++ b/.github/workflows/upm-subtree-split.yml @@ -9,22 +9,8 @@ jobs: upm-subtree-split: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: upm subtree split - run: | - # upm subtree split - git config user.name github-actions - git config user.email github-actions@github.com - $packageDir = Get-Item -Path "**/Packages/com.*" | Select-Object -ExpandProperty FullName - $packageDir = $packageDir.replace('${{ github.workspace }}/','') - Write-Host $packageDir - git subtree split --prefix="$packageDir" -b upm - git checkout upm - git fetch origin upm - git rebase origin/upm --reapply-cherry-picks - git push origin upm --force-with-lease --tags --set-upstream --verbose - working-directory: ${{ github.workspace }} - shell: pwsh + - uses: RageAgainstThePixel/upm-subtree-split@v1 diff --git a/HuggingFace/.editorconfig b/HuggingFace/.editorconfig index ac4472f..4db919a 100644 --- a/HuggingFace/.editorconfig +++ b/HuggingFace/.editorconfig @@ -1,7 +1,7 @@ -# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options +root = true +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options # Remove the line below if you want to inherit .editorconfig settings from higher directories -root = true [*.cs] @@ -12,6 +12,8 @@ indent_size = 4 indent_style = space tab_width = 4 +file_header_template = Licensed under the MIT License. See LICENSE in the project root for license information. + # New line preferences end_of_line = crlf insert_final_newline = true @@ -37,39 +39,42 @@ csharp_style_var_when_type_is_apparent = true #### Resharper/Rider Rules #### # https://www.jetbrains.com/help/resharper/EditorConfig_Properties.html -resharper_csharp_force_attribute_style=separate -csharp_place_field_attribute_on_same_line=false -csharp_place_accessorholder_attribute_on_same_line=false -csharp_trailing_comma_in_multiline_lists=false -csharp_trailing_comma_in_singleline_lists=false -csharp_keep_existing_attribute_arrangement=false -csharp_blank_lines_around_region=1 -csharp_blank_lines_inside_region=1 -csharp_keep_blank_lines_in_code=false -csharp_remove_blank_lines_near_braces_in_code=true -csharp_blank_lines_before_control_transfer_statements=1 -csharp_blank_lines_after_control_transfer_statements=1 -csharp_blank_lines_before_block_statements=1 -csharp_blank_lines_after_block_statements=1 -csharp_blank_lines_before_multiline_statements=1 -csharp_blank_lines_after_multiline_statements=1 -csharp_blank_lines_around_block_case_section=0 -csharp_blank_lines_around_multiline_case_section=0 -csharp_blank_lines_before_case=0 -csharp_blank_lines_after_case=0 -resharper_unity_duplicate_event_function_highlighting=error -resharper_unity_duplicate_shortcut_highlighting=error -resharper_unity_expected_component_highlighting=error -resharper_unity_explicit_tag_comparison_highlighting=error -resharper_unity_incorrect_mono_behaviour_instantiation_highlighting=error -resharper_unity_incorrect_scriptable_object_instantiation_highlighting=error -resharper_unity_no_null_coalescing_highlighting=error -resharper_unity_performance_critical_code_camera_main_highlighting=error -resharper_unity_performance_critical_code_invocation_highlighting=warning -resharper_unity_performance_critical_code_null_comparison_highlighting=warning -resharper_unity_possible_misapplication_of_attribute_to_multiple_fields_highlighting=error -resharper_unity_redundant_attribute_on_target_highlighting=error -resharper_unity_redundant_formerly_serialized_as_attribute_highlighting=error -resharper_unity_unresolved_component_or_scriptable_object_highlighting=error -resharper_use_name_of_instead_of_type_of_highlighting=error -resharper_wrong_public_modifier_specification_highlighting=error +resharper_csharp_force_attribute_style = separate +csharp_place_field_attribute_on_same_line = false +csharp_place_accessorholder_attribute_on_same_line = false +csharp_trailing_comma_in_multiline_lists = false +csharp_trailing_comma_in_singleline_lists = false +csharp_keep_existing_attribute_arrangement = false +csharp_blank_lines_around_region = 1 +csharp_blank_lines_inside_region = 1 +csharp_keep_blank_lines_in_code = false +csharp_remove_blank_lines_near_braces_in_code = true +csharp_blank_lines_before_control_transfer_statements = 1 +csharp_blank_lines_after_control_transfer_statements = 1 +csharp_blank_lines_before_block_statements = 1 +csharp_blank_lines_after_block_statements = 1 +csharp_blank_lines_before_multiline_statements = 1 +csharp_blank_lines_after_multiline_statements = 1 +csharp_blank_lines_around_block_case_section = 0 +csharp_blank_lines_around_multiline_case_section = 0 +csharp_blank_lines_before_case = 0 +csharp_blank_lines_after_case = 0 +resharper_unity_duplicate_event_function_highlighting = error +resharper_unity_duplicate_shortcut_highlighting = error +resharper_unity_expected_component_highlighting = error +resharper_unity_explicit_tag_comparison_highlighting = error +resharper_unity_incorrect_mono_behaviour_instantiation_highlighting = error +resharper_unity_incorrect_scriptable_object_instantiation_highlighting = error +resharper_unity_no_null_coalescing_highlighting = error +resharper_unity_performance_critical_code_camera_main_highlighting = error +resharper_unity_performance_critical_code_invocation_highlighting = warning +resharper_unity_performance_critical_code_null_comparison_highlighting = warning +resharper_unity_possible_misapplication_of_attribute_to_multiple_fields_highlighting = error +resharper_unity_redundant_attribute_on_target_highlighting = error +resharper_unity_redundant_formerly_serialized_as_attribute_highlighting = error +resharper_unity_unresolved_component_or_scriptable_object_highlighting = error +resharper_use_name_of_instead_of_type_of_highlighting = error +resharper_wrong_public_modifier_specification_highlighting = error + +# ReSharper inspection severities +resharper_arrange_attributes_highlighting = suggestion diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Hub/HubEndpoint.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Hub/HubEndpoint.cs index 6779cb8..c21aaae 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Hub/HubEndpoint.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Hub/HubEndpoint.cs @@ -31,7 +31,7 @@ public async Task GetModelTagsAsync(CancellationToken cancella { var response = await Rest.GetAsync(GetUrl("models-tags-by-type"), parameters: new RestParameters(client.DefaultRequestHeaders), cancellationToken); response.Validate(); - return JsonConvert.DeserializeObject(response.Body, client.JsonSerializationOptions); + return JsonConvert.DeserializeObject(response.Body, HuggingFaceClient.JsonSerializationOptions); } /// @@ -51,7 +51,7 @@ public async Task> ListModelsAsync(ModelSearchArguments var response = await Rest.GetAsync(uriBuilder.Uri.ToString(), parameters: new RestParameters(client.DefaultRequestHeaders), cancellationToken); response.Validate(); - return JsonConvert.DeserializeObject>(response.Body, client.JsonSerializationOptions); + return JsonConvert.DeserializeObject>(response.Body, HuggingFaceClient.JsonSerializationOptions); } /// @@ -96,7 +96,7 @@ public async Task GetModelDetailsAsync(string repoId, string revision var response = await Rest.GetAsync(uriBuilder.Uri.ToString(), parameters: new RestParameters(client.DefaultRequestHeaders), cancellationToken); response.Validate(); - return JsonConvert.DeserializeObject(response.Body, client.JsonSerializationOptions); + return JsonConvert.DeserializeObject(response.Body, HuggingFaceClient.JsonSerializationOptions); } /// @@ -108,7 +108,7 @@ public async Task> GetAllTasksAsync(Cancel { var response = await Rest.GetAsync(GetUrl("tasks"), parameters: new RestParameters(client.DefaultRequestHeaders), cancellationToken); response.Validate(); - return JsonConvert.DeserializeObject>(response.Body, client.JsonSerializationOptions); + return JsonConvert.DeserializeObject>(response.Body, HuggingFaceClient.JsonSerializationOptions); } /// @@ -208,7 +208,7 @@ public async Task WhoAmIAsync(CancellationToken cancellationToken = de { var response = await Rest.GetAsync(GetUrl("whoami-v2"), parameters: new RestParameters(client.DefaultRequestHeaders), cancellationToken); response.Validate(); - return JsonConvert.DeserializeObject(response.Body, client.JsonSerializationOptions); + return JsonConvert.DeserializeObject(response.Body, HuggingFaceClient.JsonSerializationOptions); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/HuggingFaceClient.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/HuggingFaceClient.cs index e141ad4..070637a 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/HuggingFaceClient.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/HuggingFaceClient.cs @@ -22,12 +22,6 @@ public class HuggingFaceClient : BaseClient DefaultRequestHeaders = new Dictionary { #if !UNITY_WEBGL - {"User-Agent", "com.rest.huggingface" }, + { "User-Agent", "com.rest.huggingface" }, #endif - {"Authorization", Rest.GetBearerOAuthToken(Authentication.Info.ApiKey) } + { "Authorization", Rest.GetBearerOAuthToken(Authentication.Info.ApiKey) } }; public override bool HasValidAuthentication => !string.IsNullOrWhiteSpace(Authentication?.Info?.ApiKey); - internal JsonSerializerSettings JsonSerializationOptions { get; } + internal static JsonSerializerSettings JsonSerializationOptions { get; } = new JsonSerializerSettings + { + DefaultValueHandling = DefaultValueHandling.Ignore, + NullValueHandling = NullValueHandling.Ignore, + }; public HubEndpoint HubEndpoint { get; } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/AudioToAudio/AudioToAudioResponse.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/AudioToAudio/AudioToAudioResponse.cs index 2e36401..eb07122 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/AudioToAudio/AudioToAudioResponse.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/AudioToAudio/AudioToAudioResponse.cs @@ -57,7 +57,7 @@ private static async Task DecodeAudioAsync(AudioToAudioResult result, bool debug await fileStream.DisposeAsync(); } - result.AudioClip = await Rest.DownloadAudioClipAsync($"file://{localFilePath}", AudioType.MPEG, debug: debug, cancellationToken: cancellationToken); + result.AudioClip = await Rest.DownloadAudioClipAsync($"file://{localFilePath}", AudioType.MPEG, parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/TextToSpeech/TextToSpeechResponse.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/TextToSpeech/TextToSpeechResponse.cs index 43fa9fd..c6dfd46 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/TextToSpeech/TextToSpeechResponse.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Audio/TextToSpeech/TextToSpeechResponse.cs @@ -46,7 +46,7 @@ public override async Task DecodeAsync(Stream stream, bool debug = false, Cancel await fileStream.DisposeAsync(); } - AudioClip = await Rest.DownloadAudioClipAsync($"file://{filePath}", AudioType.MPEG, debug: debug, cancellationToken: cancellationToken); + AudioClip = await Rest.DownloadAudioClipAsync($"file://{filePath}", AudioType.MPEG, parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageSegmentation/ImageSegmentationResponse.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageSegmentation/ImageSegmentationResponse.cs index 6f186e9..41a8d8a 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageSegmentation/ImageSegmentationResponse.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageSegmentation/ImageSegmentationResponse.cs @@ -54,7 +54,7 @@ private static async Task DecodeImageAsync(ImageSegmentationResult result, bool await fileStream.DisposeAsync(); } - result.Mask = await Rest.DownloadTextureAsync($"file://{localFilePath}", debug: debug, cancellationToken: cancellationToken); + result.Mask = await Rest.DownloadTextureAsync($"file://{localFilePath}", parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageToImage/ImageToImageResponse.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageToImage/ImageToImageResponse.cs index 1bf812b..a24e82c 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageToImage/ImageToImageResponse.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/ComputerVision/ImageToImage/ImageToImageResponse.cs @@ -46,7 +46,7 @@ public override async Task DecodeAsync(Stream stream, bool debug = false, Cancel await fileStream.DisposeAsync(); } - Image = await Rest.DownloadTextureAsync($"file://{filePath}", debug: debug, cancellationToken: cancellationToken); + Image = await Rest.DownloadTextureAsync($"file://{filePath}", parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/InferenceEndpoint.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/InferenceEndpoint.cs index 5153ec2..60d8d3d 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/InferenceEndpoint.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/InferenceEndpoint.cs @@ -58,7 +58,7 @@ async Task CallEndpointAsync() headers.Add("Accept", task.MimeType); } - var jsonData = await task.ToJsonAsync(client.JsonSerializationOptions, cancellationToken).ConfigureAwait(true); + var jsonData = await task.ToJsonAsync(HuggingFaceClient.JsonSerializationOptions, cancellationToken).ConfigureAwait(true); if (!string.IsNullOrWhiteSpace(jsonData)) { @@ -116,7 +116,7 @@ async Task CallEndpointAsync() if (typeof(JsonInferenceTaskResponse).IsAssignableFrom(typeof(TResponse))) { - var jsonResponse = Activator.CreateInstance(typeof(TResponse), response.Body, client.JsonSerializationOptions) as TResponse; + var jsonResponse = Activator.CreateInstance(typeof(TResponse), response.Body, HuggingFaceClient.JsonSerializationOptions) as TResponse; if (jsonResponse is B64JsonInferenceTaskResponse b64JsonInferenceTaskResponse) { diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageB64Response.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageB64Response.cs index 9d09600..bcc5561 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageB64Response.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageB64Response.cs @@ -53,7 +53,7 @@ public override async Task DecodeAsync(bool debug = false, CancellationToken can await fileStream.DisposeAsync(); } - Image = await Rest.DownloadTextureAsync($"file://{localFilePath}", debug: debug, cancellationToken: cancellationToken); + Image = await Rest.DownloadTextureAsync($"file://{localFilePath}", parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageBinaryResponse.cs b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageBinaryResponse.cs index da3c599..b13dfc3 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageBinaryResponse.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Runtime/Inference/Multimodal/TextToImage/TextToImageBinaryResponse.cs @@ -45,7 +45,7 @@ public override async Task DecodeAsync(Stream stream, bool debug, CancellationTo await fileStream.DisposeAsync(); } - Image = await Rest.DownloadTextureAsync($"file://{localFilePath}", debug: debug, cancellationToken: cancellationToken); + Image = await Rest.DownloadTextureAsync($"file://{localFilePath}", parameters: new RestParameters(debug: debug), cancellationToken: cancellationToken); } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/Tests/AbstractTestFixture.cs b/HuggingFace/Packages/com.rest.huggingface/Tests/AbstractTestFixture.cs index 9116588..7b42a3e 100644 --- a/HuggingFace/Packages/com.rest.huggingface/Tests/AbstractTestFixture.cs +++ b/HuggingFace/Packages/com.rest.huggingface/Tests/AbstractTestFixture.cs @@ -10,8 +10,10 @@ public AbstractTestFixture() { var auth = new HuggingFaceAuthentication().LoadDefaultsReversed(); var settings = new HuggingFaceSettings(); - HuggingFaceClient = new HuggingFaceClient(auth, settings); - //HuggingFaceClient.EnableDebug = true; + HuggingFaceClient = new HuggingFaceClient(auth, settings) + { + EnableDebug = true + }; } } } diff --git a/HuggingFace/Packages/com.rest.huggingface/package.json b/HuggingFace/Packages/com.rest.huggingface/package.json index 2dec4a3..ce58694 100644 --- a/HuggingFace/Packages/com.rest.huggingface/package.json +++ b/HuggingFace/Packages/com.rest.huggingface/package.json @@ -3,7 +3,7 @@ "displayName": "HuggingFace", "description": "A Non-Official HuggingFace Rest Client for Unity (UPM)", "keywords": [], - "version": "1.0.0-preview.14", + "version": "1.0.0-preview.15", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.rest.huggingface#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.rest.huggingface/releases", @@ -20,9 +20,9 @@ "registry": "https://package.openupm.com" }, "dependencies": { - "com.utilities.rest": "2.4.0", - "com.utilities.encoder.wav": "1.1.3", - "com.utilities.encoder.ogg": "3.1.1" + "com.utilities.rest": "2.5.0", + "com.utilities.encoder.wav": "1.1.4", + "com.utilities.encoder.ogg": "3.1.2" }, "hideInEditor": false } \ No newline at end of file diff --git a/HuggingFace/Packages/manifest.json b/HuggingFace/Packages/manifest.json index 31c48fc..3db231b 100644 --- a/HuggingFace/Packages/manifest.json +++ b/HuggingFace/Packages/manifest.json @@ -1,9 +1,9 @@ { "dependencies": { - "com.unity.ide.rider": "3.0.26", + "com.unity.ide.rider": "3.0.27", "com.unity.ide.visualstudio": "2.0.22", "com.unity.test-framework": "1.1.33", - "com.utilities.buildpipeline": "1.1.9" + "com.utilities.buildpipeline": "1.2.1" }, "scopedRegistries": [ { diff --git a/HuggingFace/ProjectSettings/ProjectVersion.txt b/HuggingFace/ProjectSettings/ProjectVersion.txt index 2e7bb8a..0ab53b0 100644 --- a/HuggingFace/ProjectSettings/ProjectVersion.txt +++ b/HuggingFace/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.15f1 -m_EditorVersionWithRevision: 2022.3.15f1 (b58023a2b463) +m_EditorVersion: 2022.3.16f1 +m_EditorVersionWithRevision: 2022.3.16f1 (d2c21f0ef2f1)