Skip to content

Commit

Permalink
nonmem: add empty WK_ files to list of files to clean up
Browse files Browse the repository at this point in the history
Under --parallel, NONMEM creates several WK_* files.  These are worker
files created for parallelization problems and are used as file
buffers.  The NONMEM Users Guide Introduction to NONMEM 7.5.0 (pg 73)
says

  One can alternatively assess empirically whether file buffers are
  used, by beginning the run, allowing perhaps one iteration to
  transpire, then from another command window do a directory search
  for FILE*, (or WK* for worker files in parallelization problems,
  section I.72 Parallel Computing (NM72)

  If any of the FILExx do not have 0 size, then they are being
  used. Interrupt the analysis, then increase the appropriate LIM
  value with the $SIZES record [...]

So, a non-empty file is a signal that the user probably wants to make
adjustments so that everything fits into memory.  An empty file, on
the other hand, is safe for us to clean up [*].

Due to the regexp match and the extra size condition, this doesn't
work nicely as part of getCleanableFileList().  filesToCleanup()
already has special handling for some parallelization, so add the WK
handling there.

[*] NONMEM cleans up FILE* buffer files after a run.  I'm not sure why
    it doesn't also clean up WK*.

Re: #285
  • Loading branch information
kyleam committed Sep 22, 2023
1 parent 94793a9 commit 42d8194
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/nonmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ func filesToCleanup(model *NonMemModel, exceptions ...string) runner.FileCleanIn
}
}
}

re_wk := regexp.MustCompile("^WK_[0-9]+")
for _, f := range files {
if f.Size() == 0 && !f.IsDir() && re_wk.MatchString(f.Name()) {
fci.FilesToRemove = append(fci.FilesToRemove, newTargetFile(f.Name(), model.Configuration.CleanLvl))
}
}
}

return fci
Expand Down
7 changes: 7 additions & 0 deletions integration/nonmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ func AssertNonMemCleanedUpFiles(t *wrapt.T, details NonMemTestingDetails) {
t.A.NoFileExists(filepath.Join(details.OutputDir, f))
}
}

// Parallelization-related files handled by nonmem.filesToCleanup().
files, err := os.ReadDir(details.OutputDir)
t.R.NoError(err)
for _, fi := range files {
t.R.NotRegexp("^WK_", fi.Name())
}
}

func AssertBBIConfigJSONCreated(t *wrapt.T, details NonMemTestingDetails) {
Expand Down

0 comments on commit 42d8194

Please sign in to comment.