Skip to content

Commit

Permalink
Merge pull request #13 from phac-nml/fix/sync
Browse files Browse the repository at this point in the history
Fix/sync
  • Loading branch information
apetkau authored Jan 21, 2024
2 parents ea264b6 + 623d54e commit fd24a76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class IridaNextJSONOutput {
try {
// validate all JSON against passed schema prior to writing
if (validate && jsonSchema != null) {
log.debug "Validating IRIDA Next output against schema ${jsonSchema.getUri()} prior to writing to ${path}"
validateJson(jsonString)
log.debug "Validation successfull against schema ${jsonSchema.getUri()} for JSON prior to writing to ${path}"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import java.nio.file.PathMatcher
import java.net.URI

import groovy.transform.CompileStatic
import groovy.transform.Synchronized
import groovy.util.logging.Slf4j
import groovy.json.JsonOutput
import nextflow.Session
Expand Down Expand Up @@ -51,6 +52,8 @@ import nextflow.iridanext.MetadataParserJSON
@Slf4j
@CompileStatic
class IridaNextObserver implements TraceObserver {
private static final tasksLock = new Object[0]
private static final publishedFilesLock = new Object[0]

private Map<Path,Path> publishedFiles = [:]
private List<TaskRun> tasks = []
Expand Down Expand Up @@ -98,13 +101,15 @@ class IridaNextObserver implements TraceObserver {
}

@Override
@Synchronized("tasksLock")
void onProcessComplete(TaskHandler handler, TraceRecord trace) {
log.trace "onProcessComplete: ${handler.task}"
tasks << handler.task
traces << trace
}

@Override
@Synchronized("tasksLock")
void onProcessCached(TaskHandler handler, TraceRecord trace) {
log.trace "onProcessCached: ${handler.task}"
tasks << handler.task
Expand Down Expand Up @@ -217,6 +222,7 @@ class IridaNextObserver implements TraceObserver {
}

@Override
@Synchronized("publishedFilesLock")
void onFilePublish(Path destination, Path source) {
if (publishedFiles.containsKey(source)) {
throw new Exception("Error: file with source=${source} was already published")
Expand Down

0 comments on commit fd24a76

Please sign in to comment.