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

WM-1414 Refactoring WesRunLog to omit Cromwell's "workflowLog" object #6925

Merged
merged 2 commits into from
Oct 11, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package cromwell.webservice.routes.wes

import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import cromwell.webservice.routes.wes.WesState.WesState
import spray.json.{DefaultJsonProtocol, RootJsonFormat}
import cromwell.webservice.routes.wes.WesRunLog
import spray.json.{DefaultJsonProtocol, JsObject, RootJsonFormat}

sealed trait WesResponse extends Product with Serializable
final case class WesErrorResponse(msg: String, status_code: Int) extends WesResponse
Expand All @@ -12,6 +11,18 @@ final case class WesRunStatus(run_id: String, state: WesState) extends WesRespon
final case class WesResponseRunList(runs: List[WesRunStatus]) extends WesResponse
final case class WesResponseWorkflowMetadata(workflowLog: WesRunLog) extends WesResponse

final case class WesRunLog(run_id: String,
request: WesRunRequest,
state: WesState,
run_log: Option[WesLog],
task_logs: Option[List[WesLog]],
outputs: Option[JsObject]
) extends WesResponse

object WesRunLog {
def fromJson(json: String): WesRunLog = CromwellMetadata.fromJson(json).wesRunLog
}


final case class WesStatusInfoResponse(workflow_type_version: Map[String, Iterable[String]],
supported_wes_versions: Iterable[String],
Expand Down Expand Up @@ -48,6 +59,7 @@ object WesResponseJsonSupport extends SprayJsonSupport with DefaultJsonProtocol
case i: WesStatusInfoResponse => i.toJson
case l: WesResponseRunList => l.toJson
case m: WesResponseWorkflowMetadata => m.toJson
case w: WesRunLog => w.toJson
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ object WesRouteSupport {
val metadataJsonResponse = metadataBuilderActorRequest(workflowId, request, serviceRegistryActor)

metadataJsonResponse.map {
case SuccessfulMetadataJsonResponse(_, responseJson) => WesResponseWorkflowMetadata(WesRunLog.fromJson(responseJson.toString()))
case SuccessfulMetadataJsonResponse(_, responseJson) => WesRunLog.fromJson(responseJson.toString())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need to update response definition in Swagger?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this works without having to update it.

case FailedMetadataJsonResponse(_, reason) => WesErrorResponse(reason.getMessage, StatusCodes.InternalServerError.intValue)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cromwell.webservice.routes.wes

import cromwell.webservice.routes.wes.WesState.WesState
import spray.json.JsObject


Expand All @@ -20,15 +19,3 @@ final case class WesRunRequest(workflow_params: Option[JsObject],
workflow_engine_parameters: Option[JsObject],
workflow_url: Option[String]
)

final case class WesRunLog(run_id: String,
request: WesRunRequest,
state: WesState,
run_log: Option[WesLog],
task_logs: Option[List[WesLog]],
outputs: Option[JsObject]
)

object WesRunLog {
def fromJson(json: String): WesRunLog = CromwellMetadata.fromJson(json).wesRunLog
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class WesRouteSupportSpec extends AsyncFlatSpec with ScalatestRouteTest with Mat
wesRoutes ~>
check {
status should be(StatusCodes.OK)
val result = responseAs[JsObject].fields("workflowLog").asJsObject()
val result = responseAs[JsObject]
result.fields.keys should contain allOf("request", "run_id", "state")
result.fields("state") should be(JsString("RUNNING"))
result.fields("run_id") should be(JsString(CromwellApiServiceSpec.wesWorkflowId.toString))
Expand Down