Skip to content

Commit

Permalink
Extend onFilePublish notification adding source path (#3284)
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Grande <bruno.grande@sagebase.org>
Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
Bruno Grande and pditommaso committed Nov 9, 2022
1 parent 4a336a6 commit 81acc3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,11 @@ class Session implements ISession {
observers.each { trace -> trace.onFlowCreate(this) }
}

void notifyFilePublish(Path destination) {
void notifyFilePublish(Path destination, Path source) {
def copy = new ArrayList<TraceObserver>(observers)
for( TraceObserver observer : copy ) {
try {
observer.onFilePublish(destination)
observer.onFilePublish(destination, source)
}
catch( Exception e ) {
log.error "Failed to invoke observer on file publish: $observer", e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class PublishDir {
processFileImpl(source, destination)
}

notifyFilePublish(destination)
notifyFilePublish(destination, source)
}

private String real0(Path p) {
Expand Down Expand Up @@ -506,10 +506,10 @@ class PublishDir {
}
}

protected void notifyFilePublish(Path destination) {
protected void notifyFilePublish(Path destination, Path source=null) {
final sess = Global.session
if (sess instanceof Session) {
sess.notifyFilePublish(destination)
sess.notifyFilePublish(destination, source)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,17 @@ trait TraceObserver {
* The destination path at `publishDir` folder.
*/
void onFilePublish(Path destination){}

/**
* Method that is invoke when an output file is published
* into a `publishDir` folder.
*
* @param destination
* The destination path at `publishDir` folder.
* @param source
* The source path at `workDir` folder.
*/
void onFilePublish(Path destination, Path source){
onFilePublish(destination)
}
}

0 comments on commit 81acc3e

Please sign in to comment.