-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/348 create checkpoint v2 #407
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
Merged
salamonpavel
merged 13 commits into
feature/347-v2-endpoints-in-dispatcher
from
feature/348-create-checkpoint-v2
Jan 12, 2026
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6e6fc81
tmp
salamonpavel 5059f31
Merge branch 'feature/347-v2-endpoints-in-dispatcher' into feature/34…
salamonpavel 64c963b
save checkpoint uses v2 endpoints
salamonpavel e2944ce
first version
salamonpavel 5442502
tests fixed
salamonpavel b6e2eac
SerializationUtilsUnitTests commented out
salamonpavel c6d81e5
test fixes
salamonpavel d2f18d6
refactoring
salamonpavel 3177a57
clean up
salamonpavel 21b2091
api test fix
salamonpavel 97451e4
Merge branch 'feature/347-v2-endpoints-in-dispatcher' into feature/34…
salamonpavel bd4305c
pr comments addressed
salamonpavel a3ffff1
.toMap conversion removed
salamonpavel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import sttp.capabilities | |
| import sttp.client3._ | ||
| import sttp.model.Uri | ||
| import sttp.client3.okhttp.OkHttpSyncBackend | ||
| import sttp.model.StatusCode | ||
| import za.co.absa.atum.agent.exception.AtumAgentException.HttpException | ||
| import za.co.absa.atum.model.ApiPaths | ||
| import za.co.absa.atum.model.dto._ | ||
|
|
@@ -33,7 +34,6 @@ class HttpDispatcher(config: Config) extends Dispatcher(config) with Logging { | |
|
|
||
| private val serverUrl: String = config.getString(UrlKey) | ||
|
|
||
| private val apiV1 = s"/${ApiPaths.Api}/${ApiPaths.V1}" | ||
| private val apiV2 = s"/${ApiPaths.Api}/${ApiPaths.V2}" | ||
|
|
||
| private val getPartitioningIdEndpoint = Uri.unsafeParse(s"$serverUrl$apiV2/${ApiPaths.V2Paths.Partitionings}") | ||
|
|
@@ -64,8 +64,8 @@ class HttpDispatcher(config: Config) extends Dispatcher(config) with Logging { | |
|
|
||
| val response = backend.send(request) | ||
|
|
||
| response.code.code match { | ||
| case 404 => None | ||
| response.code match { | ||
| case StatusCode.NotFound => None | ||
| case _ => Some(handleResponseBody(response).as[SingleSuccessResponse[PartitioningWithIdDTO]].data) | ||
| } | ||
| } | ||
|
|
@@ -74,6 +74,8 @@ class HttpDispatcher(config: Config) extends Dispatcher(config) with Logging { | |
| val parentPartitioningIdOpt = partitioning.parentPartitioning.map(getPartitioningId) | ||
| val partitioningWithIdOpt = getPartitioning(partitioning.partitioning) | ||
|
|
||
|
|
||
|
||
|
|
||
| val newPartitioningWithIdDTO = partitioningWithIdOpt.getOrElse { | ||
| val endpoint = Uri.unsafeParse(s"$serverUrl$apiV2/${ApiPaths.V2Paths.Partitionings}") | ||
| val request = commonAtumRequest | ||
|
|
@@ -104,27 +106,40 @@ class HttpDispatcher(config: Config) extends Dispatcher(config) with Logging { | |
| ) | ||
| val req = commonAtumRequest.get(endpoint) | ||
| val resp = backend.send(req) | ||
| handleResponseBody(resp) | ||
| .as[SingleSuccessResponse[AdditionalDataDTO.Data]] | ||
| .data | ||
| .map(item => item._1 -> item._2.map(_.value)) | ||
|
|
||
|
||
|
|
||
| handleResponseBody(resp).as[MultiSuccessResponse[AdditionalDataItemV2DTO]] | ||
| } | ||
|
|
||
| AtumContextDTO( | ||
| partitioning = newPartitioningWithIdDTO.partitioning, | ||
| measures = measures, | ||
| additionalData = additionalData | ||
| additionalData = additionalData.data.map(item => item.key -> item.value).toMap | ||
| ) | ||
| } | ||
|
|
||
| override protected[agent] def saveCheckpoint(checkpoint: CheckpointDTO): Unit = { | ||
| val endpoint = Uri.unsafeParse(s"$serverUrl$apiV1/${ApiPaths.V1Paths.CreateCheckpoint}") | ||
| val partitioningId = getPartitioningId(checkpoint.partitioning) | ||
|
|
||
| val checkpointV2DTO = CheckpointV2DTO( | ||
| id = checkpoint.id, | ||
| name = checkpoint.name, | ||
| author = checkpoint.author, | ||
| measuredByAtumAgent = checkpoint.measuredByAtumAgent, | ||
| processStartTime = checkpoint.processStartTime, | ||
| processEndTime = checkpoint.processEndTime, | ||
| measurements = checkpoint.measurements, | ||
| properties = checkpoint.properties | ||
| ) | ||
|
|
||
| val endpoint = Uri.unsafeParse( | ||
| s"$serverUrl$apiV2/${ApiPaths.V2Paths.Partitionings}/$partitioningId/${ApiPaths.V2Paths.Checkpoints}" | ||
| ) | ||
| val request = commonAtumRequest | ||
| .post(endpoint) | ||
| .body(checkpoint.asJsonString) | ||
| .body(checkpointV2DTO.asJsonString) | ||
|
|
||
| val response = backend.send(request) | ||
|
|
||
| handleResponseBody(response) | ||
| } | ||
|
|
||
|
|
@@ -145,7 +160,14 @@ class HttpDispatcher(config: Config) extends Dispatcher(config) with Logging { | |
|
|
||
| val response = backend.send(request) | ||
|
|
||
| handleResponseBody(response).as[SingleSuccessResponse[AdditionalDataDTO]].data | ||
| val data: AdditionalDataDTO.Data = handleResponseBody(response).as[MultiSuccessResponse[AdditionalDataItemV2DTO]] | ||
| .data | ||
| .map( item => item.value match { | ||
| case Some(_) => item.key -> Some(AdditionalDataItemDTO(item.value.get, item.author)) | ||
| case None => item.key -> None | ||
| }).toMap | ||
|
|
||
| AdditionalDataDTO(data) | ||
| } | ||
|
|
||
| private def handleResponseBody(response: Response[Either[String, String]]): String = { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be needed
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is needed as now the data come from multisuccessresponse as a sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry looked at wrong class