Skip to content

Commit

Permalink
Merge pull request #91 from nextflow-io/observer-check
Browse files Browse the repository at this point in the history
Move unpinned version check to an observer
  • Loading branch information
nvnieuwk authored Jan 21, 2025
2 parents 08154f5 + 4cbe4f6 commit 726d265
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Version 2.4.0dev

## Bug fixes

1. Move the unpinned version check to an observer. This makes sure the warning is always shown and not only when importing a function.

## Changes

1. Refactored the whole codebase to make future development easier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,6 @@ class ValidationExtension extends PluginExtensionPoint {

@Override
protected void init(Session session) {
def plugins = session?.config?.navigate("plugins") as ArrayList
// TODO move the warning to an observer
if(plugins?.contains("nf-schema")) {
log.warn("""
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !
! WARNING! !
! !
! You just entered the danger zone! !
! Please pin the nf-schema version in your config! !
! Not pinning your version can't guarantee the reproducibility !
! and the functionality of this pipeline in the future !
! !
! plugins { !
! id "nf-schema@<version>" !
! } !
! !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
""")
}

this.session = session

// Help message logic
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package nextflow.validation

import nextflow.Session
import nextflow.trace.TraceObserver

import groovy.util.logging.Slf4j

/**
* An observer for initial checks that always need to be run at the start of the pipeline
*
* @author : nvnieuwk <[email protected]>
*/


@Slf4j
class ValidationObserver implements TraceObserver {

@Override
void onFlowCreate(Session session) {
def plugins = session?.config?.navigate("plugins") as ArrayList
if(plugins?.contains("nf-schema")) {
log.warn("""
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !
! WARNING! !
! !
! You just entered the danger zone! !
! Please pin the nf-schema version in your config! !
! Not pinning your version can't guarantee the reproducibility !
! and the functionality of this pipeline in the future !
! !
! plugins { !
! id "nf-schema@<version>" !
! } !
! !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
""")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ValidationObserverFactory implements TraceObserverFactory {

@Override
Collection<TraceObserver> create(Session session) {
def List observers = []
def List observers = [ new ValidationObserver() ]
// Only enable the help observer when a help message needs to be printed
if(session.config.navigate('validation.help.enabled')) {
observers.add(new HelpObserver())
Expand Down

0 comments on commit 726d265

Please sign in to comment.