Skip to content

Commit

Permalink
Mark corpus endpoints obsolete (#535)
Browse files Browse the repository at this point in the history
* Mark corpus endpoints obsolete
* ignore CS0612 obsolete endpoint warnings in E2E and integration tests

* Mark corpus dto properties obsolete.

* use pragmas for obsolete ignoring
  • Loading branch information
johnml1135 authored Nov 5, 2024
1 parent c45a597 commit 57ce385
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 27 deletions.
56 changes: 38 additions & 18 deletions src/Serval/src/Serval.Client/Client.g.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

public record PretranslateCorpusConfigDto
{
[Obsolete]
public string? CorpusId { get; init; }

[Obsolete]
public IReadOnlyList<string>? TextIds { get; init; }

[Obsolete]
public string? ScriptureRange { get; init; }

public string? ParallelCorpusId { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

public record PretranslateCorpusDto
{
[Obsolete]
public ResourceLinkDto? Corpus { get; init; }

[Obsolete]
public IReadOnlyList<string>? TextIds { get; init; }

[Obsolete]
public string? ScriptureRange { get; init; }

public ResourceLinkDto? ParallelCorpus { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ namespace Serval.Translation.Contracts;

public record TrainingCorpusConfigDto
{
[Obsolete]
public string? CorpusId { get; init; }

[Obsolete]
public IReadOnlyList<string>? TextIds { get; init; }

[Obsolete]
public string? ScriptureRange { get; init; }

public string? ParallelCorpusId { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ namespace Serval.Translation.Contracts;

public record TrainingCorpusDto
{
[Obsolete]
public ResourceLinkDto? Corpus { get; init; }

[Obsolete]
public IReadOnlyList<string>? TextIds { get; init; }

[Obsolete]
public string? ScriptureRange { get; init; }

public ResourceLinkDto? ParallelCorpus { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Serval.Translation.Controllers;

#pragma warning disable CS0612 // Type or member is obsolete

[ApiVersion(1.0)]
[Route("api/v{version:apiVersion}/translation/engines")]
[OpenApiTag("Translation Engines")]
Expand Down Expand Up @@ -315,7 +317,7 @@ await _engineService.TrainSegmentPairAsync(
}

/// <summary>
/// Add a corpus to a translation engine
/// Add a corpus to a translation engine (obsolete - use parallel corpora instead)
/// </summary>
/// <remarks>
/// ## Parameters
Expand Down Expand Up @@ -346,6 +348,7 @@ await _engineService.TrainSegmentPairAsync(
/// <response code="403">The authenticated client cannot perform the operation or does not own the translation engine.</response>
/// <response code="404">The engine does not exist.</response>
/// <response code="503">A necessary service is currently unavailable. Check `/health` for more details.</response>
[Obsolete("This endpoint is obsolete. Use parallel corpora instead.")]
[Authorize(Scopes.UpdateTranslationEngines)]
[HttpPost("{id}/corpora")]
[ProducesResponseType(StatusCodes.Status201Created)]
Expand All @@ -371,7 +374,7 @@ CancellationToken cancellationToken
}

/// <summary>
/// Update a corpus with a new set of files
/// Update a corpus with a new set of files (obsolete - use parallel corpora instead)
/// </summary>
/// <remarks>
/// See posting a new corpus for details of use. Will completely replace corpus' file associations.
Expand All @@ -388,6 +391,7 @@ CancellationToken cancellationToken
/// <response code="403">The authenticated client cannot perform the operation or does not own the translation engine.</response>
/// <response code="404">The engine or corpus does not exist.</response>
/// <response code="503">A necessary service is currently unavailable. Check `/health` for more details.</response>
[Obsolete("This endpoint is obsolete. Use parallel corpora instead.")]
[Authorize(Scopes.UpdateTranslationEngines)]
[HttpPatch("{id}/corpora/{corpusId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand Down Expand Up @@ -420,7 +424,7 @@ corpusConfig.TargetFiles is null
}

/// <summary>
/// Get all corpora for a translation engine
/// Get all corpora for a translation engine (obsolete - use parallel corpora instead)
/// </summary>
/// <param name="id">The translation engine id</param>
/// <param name="cancellationToken"></param>
Expand All @@ -429,6 +433,7 @@ corpusConfig.TargetFiles is null
/// <response code="403">The authenticated client cannot perform the operation or does not own the translation engine</response>
/// <response code="404">The engine does not exist</response>
/// <response code="503">A necessary service is currently unavailable. Check `/health` for more details. </response>
[Obsolete("This endpoint is obsolete. Use parallel corpora instead.")]
[Authorize(Scopes.ReadTranslationEngines)]
[HttpGet("{id}/corpora")]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand All @@ -447,7 +452,7 @@ CancellationToken cancellationToken
}

/// <summary>
/// Get the configuration of a corpus for a translation engine
/// Get the configuration of a corpus for a translation engine (obsolete - use parallel corpora instead)
/// </summary>
/// <param name="id">The translation engine id</param>
/// <param name="corpusId">The corpus id</param>
Expand All @@ -457,6 +462,7 @@ CancellationToken cancellationToken
/// <response code="403">The authenticated client cannot perform the operation or does not own the translation engine.</response>
/// <response code="404">The engine or corpus does not exist.</response>
/// <response code="503">A necessary service is currently unavailable. Check `/health` for more details.</response>
[Obsolete("This endpoint is obsolete. Use parallel corpora instead.")]
[Authorize(Scopes.ReadTranslationEngines)]
[HttpGet("{id}/corpora/{corpusId}", Name = Endpoints.GetTranslationCorpus)]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand Down Expand Up @@ -700,7 +706,7 @@ CancellationToken cancellationToken
}

/// <summary>
/// Get all pretranslations in a corpus of a translation engine
/// Get all pretranslations in a corpus or parallel corpus of a translation engine
/// </summary>
/// <remarks>
/// Pretranslations are arranged in a list of dictionaries with the following fields per pretranslation:
Expand All @@ -714,7 +720,7 @@ CancellationToken cancellationToken
/// Only pretranslations for the most recent successful build of the engine are returned.
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="corpusId">The corpus id</param>
/// <param name="corpusId">The corpus id or parallel corpus id</param>
/// <param name="textId">The text id (optional)</param>
/// <param name="cancellationToken"></param>
/// <response code="200">The pretranslations</response>
Expand Down Expand Up @@ -763,7 +769,7 @@ CancellationToken cancellationToken
}

/// <summary>
/// Get all pretranslations for the specified text in a corpus of a translation engine
/// Get all pretranslations for the specified text in a corpus or parallel corpus of a translation engine
/// </summary>
/// <remarks>
/// Pretranslations are arranged in a list of dictionaries with the following fields per pretranslation:
Expand All @@ -776,7 +782,7 @@ CancellationToken cancellationToken
/// Only pretranslations for the most recent successful build of the engine are returned.
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="corpusId">The corpus id</param>
/// <param name="corpusId">The corpus id or parallel corpus id</param>
/// <param name="textId">The text id</param>
/// <param name="cancellationToken"></param>
/// <response code="200">The pretranslations</response>
Expand Down Expand Up @@ -843,7 +849,7 @@ CancellationToken cancellationToken
/// Both scripture and non-scripture text in the USFM is parsed and grouped according to [this wiki](https://github.com/sillsdev/serval/wiki/USFM-Parsing-and-Translation).
/// </remarks>
/// <param name="id">The translation engine id</param>
/// <param name="corpusId">The corpus id</param>
/// <param name="corpusId">The corpus id or parallel corpus id</param>
/// <param name="textId">The text id</param>
/// <param name="textOrigin">The source[s] of the data to populate the USFM file with.</param>
/// <param name="cancellationToken"></param>
Expand Down Expand Up @@ -1760,3 +1766,5 @@ private static ModelDownloadUrlDto Map(ModelDownloadUrl source)
};
}
}

#pragma warning restore CS0612 // Type or member is obsolete
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace Serval.ApiServer;

#pragma warning disable CS0612 // Type or member is obsolete

[TestFixture]
[Category("Integration")]
public class TranslationEngineTests
Expand Down Expand Up @@ -2379,3 +2381,5 @@ protected override void DisposeManagedResources()
}
}
}

#pragma warning restore CS0612 // Type or member is obsolete
4 changes: 4 additions & 0 deletions src/Serval/test/Serval.E2ETests/ServalApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Serval.E2ETests;

#pragma warning disable CS0612 // Type or member is obsolete

[TestFixture]
[Category("E2E")]
public class ServalApiTests
Expand Down Expand Up @@ -470,3 +472,5 @@ public async Task OneTimeTearDown()
await _helperClient.DisposeAsync();
}
}

#pragma warning restore CS0612 // Type or member is obsolete
4 changes: 4 additions & 0 deletions src/Serval/test/Serval.E2ETests/ServalClientHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Serval.E2ETests;

#pragma warning disable CS0612 // Type or member is obsolete

public class ServalClientHelper : IAsyncDisposable
{
public DataFilesClient DataFilesClient { get; }
Expand Down Expand Up @@ -416,3 +418,5 @@ public ValueTask DisposeAsync()
return new ValueTask(Task.CompletedTask);
}
}

#pragma warning restore CS0612 // Type or member is obsolete

0 comments on commit 57ce385

Please sign in to comment.