Skip to content

Commit

Permalink
moved logic to storeCondaLock
Browse files Browse the repository at this point in the history
Signed-off-by: munishchouhan <[email protected]>
  • Loading branch information
munishchouhan committed Dec 10, 2024
1 parent 17bd6f8 commit 04f5acb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
27 changes: 2 additions & 25 deletions src/main/groovy/io/seqera/wave/controller/ViewController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -233,31 +233,8 @@ class ViewController {
}
//add conda lock file when available
if( buildLogService && result.condaFile ) {
def condaLock = buildLogService.fetchCondaLockString(result.buildId)
def buildId = result.buildId

/*
When a container image is cached, dockerfile does not get executed.
In that case condalock file will contain "cat environment.lock" because its not been executed.
So wave will check the previous builds of that container image
and render the condalock file from latest successful build
and replace with the current build's condalock file.
*/
if ( condaLock && condaLock.contains('cat environment.lock') ) {
condaLock = null //if there is no conda lock file, don't show the conda lock data
def builds = persistenceService.allBuilds(result.buildId.split('-')[1].split('_')[0])
for (def build : builds) {
if ( build.succeeded() ){
buildId = build.buildId
condaLock = buildLogService.fetchCondaLockString(build.buildId)
if ( !condaLock.contains('cat environment.lock') )
break
}
}
}

binding.build_conda_lock_data = condaLock
binding.build_conda_lock_url = "$serverUrl/v1alpha1/builds/${buildId}/condalock"
binding.build_conda_lock_data = buildLogService.fetchCondaLockString(result.buildId)
binding.build_conda_lock_url = "$serverUrl/v1alpha1/builds/${result.buildId}/condalock"
}
// result the main object
return binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,24 @@ class BuildLogServiceImpl implements BuildLogService {
if( !logs ) return
try {
String condaLock = extractCondaLockFile(logs)
if (condaLock){
if ( condaLock ){
log.debug "Storing conda lock for buildId: $buildId"

/* When a container image is cached, dockerfile does not get executed.
In that case condalock file will contain "cat environment.lock" because its not been executed.
So wave will check the previous builds of that container image
and render the condalock file from latest successful build
and replace with the current build's condalock file.
*/
if( condaLock.contains('cat environment.lock') ){
log.info "Container Image is already cached, uploading previously successful build's condalock file for buildId: $buildId"
def builds = persistenceService.allBuilds(buildId.split('-')[1].split('_')[0])
for (def build : builds) {
if ( build.succeeded() && !condaLock.contains('cat environment.lock') ){
condaLock = fetchCondaLockString(build.buildId)
}
}
}
final uploadRequest = UploadRequest.fromBytes(condaLock.bytes, condaLockKey(buildId))
objectStorageOperations.upload(uploadRequest)
}
Expand Down

0 comments on commit 04f5acb

Please sign in to comment.