diff options
| author | Florian Gerlinghoff <gerlinghoff@live.de> | 2021-12-12 20:57:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-12 20:57:15 +0100 |
| commit | 6d9cc3e81593283f4443cd5f4c789ff61ed0c873 (patch) | |
| tree | 90d053d9139a6fc199f3412743649240847b8f54 /opendc-trace/opendc-trace-gwf/src | |
| parent | 4a83f7aca64b299d20d14f06d5d0ee3392921881 (diff) | |
fix(trace): Read dependencies from .gwf trace file (#50)
Tasks from a .gwf trace file did not have dependencies because this
property was not assigned after being read in the GwfTaskTableReader.
I removed the conversion from String to Long in parseParents because it
seems like other readers (the Parquet reader in particular) return
Strings as well, which is why they are converted to Long in line 75 of
TraceHelpers.kt.
Co-authored-by: Fabian Mastenbroek <mail.fabianm@gmail.com>
Diffstat (limited to 'opendc-trace/opendc-trace-gwf/src')
2 files changed, 24 insertions, 5 deletions
diff --git a/opendc-trace/opendc-trace-gwf/src/main/kotlin/org/opendc/trace/gwf/GwfTaskTableReader.kt b/opendc-trace/opendc-trace-gwf/src/main/kotlin/org/opendc/trace/gwf/GwfTaskTableReader.kt index aa4c543b..7f01ef2b 100644 --- a/opendc-trace/opendc-trace-gwf/src/main/kotlin/org/opendc/trace/gwf/GwfTaskTableReader.kt +++ b/opendc-trace/opendc-trace-gwf/src/main/kotlin/org/opendc/trace/gwf/GwfTaskTableReader.kt @@ -60,7 +60,7 @@ internal class GwfTaskTableReader(private val parser: CsvParser) : TableReader { "RunTime" -> runtime = Duration.ofSeconds(parser.longValue) "NProcs" -> nProcs = parser.intValue "ReqNProcs" -> reqNProcs = parser.intValue - "Dependencies" -> parseParents(parser.valueAsString) + "Dependencies" -> dependencies = parseParents(parser.valueAsString) } } @@ -119,8 +119,8 @@ internal class GwfTaskTableReader(private val parser: CsvParser) : TableReader { /** * Parse the parents into a set of longs. */ - private fun parseParents(value: String): Set<Long> { - val result = mutableSetOf<Long>() + private fun parseParents(value: String): Set<String> { + val result = mutableSetOf<String>() val deps = value.split(pattern) for (dep in deps) { @@ -128,7 +128,7 @@ internal class GwfTaskTableReader(private val parser: CsvParser) : TableReader { continue } - result.add(dep.toLong(10)) + result.add(dep) } return result @@ -156,7 +156,7 @@ internal class GwfTaskTableReader(private val parser: CsvParser) : TableReader { private var runtime: Duration? = null private var nProcs = -1 private var reqNProcs = -1 - private var dependencies = emptySet<Long>() + private var dependencies = emptySet<String>() /** * Reset the state. diff --git a/opendc-trace/opendc-trace-gwf/src/test/kotlin/org/opendc/trace/gwf/GwfTraceFormatTest.kt b/opendc-trace/opendc-trace-gwf/src/test/kotlin/org/opendc/trace/gwf/GwfTraceFormatTest.kt index 7fe403b2..5dfd02a1 100644 --- a/opendc-trace/opendc-trace-gwf/src/test/kotlin/org/opendc/trace/gwf/GwfTraceFormatTest.kt +++ b/opendc-trace/opendc-trace-gwf/src/test/kotlin/org/opendc/trace/gwf/GwfTraceFormatTest.kt @@ -69,4 +69,23 @@ internal class GwfTraceFormatTest { { assertEquals(emptySet<String>(), reader.get(TASK_PARENTS)) }, ) } + + @Test + fun testReadingRowWithDependencies() { + val path = Paths.get(checkNotNull(GwfTraceFormatTest::class.java.getResource("/trace.gwf")).toURI()) + val reader = format.newReader(path, TABLE_TASKS) + + // Move to row 7 + for (x in 1..6) + reader.nextRow() + + assertAll( + { assertTrue(reader.nextRow()) }, + { assertEquals("0", reader.get(TASK_WORKFLOW_ID)) }, + { assertEquals("7", reader.get(TASK_ID)) }, + { assertEquals(Instant.ofEpochSecond(87), reader.get(TASK_SUBMIT_TIME)) }, + { assertEquals(Duration.ofSeconds(11), reader.get(TASK_RUNTIME)) }, + { assertEquals(setOf<String>("4", "5", "6"), reader.get(TASK_PARENTS)) }, + ) + } } |
