Skip to content

Commit

Permalink
Merge pull request #206 from metrumresearchgroup/fmt/proj
Browse files Browse the repository at this point in the history
fmt: go fmt project
  • Loading branch information
seth127 authored Jan 21, 2021
2 parents 1084064 + d9d592f commit 39ae868
Show file tree
Hide file tree
Showing 26 changed files with 356 additions and 547 deletions.
371 changes: 254 additions & 117 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion babconfig.toml

This file was deleted.

9 changes: 5 additions & 4 deletions cmd/covcor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package cmd

import (
parser "bbi/parsers/nmparser"
"encoding/json"
"fmt"
parser "bbi/parsers/nmparser"
log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
Expand All @@ -28,12 +28,13 @@ const covcorLongDescription string = `load .cov and .cor output from model(s), f
bbi nonmem covcor run001/run001
bbi nonmem covcor run001/run001.cov
`

// runCmd represents the run command
var covcorCmd = &cobra.Command{
Use: "covcor",
Short: "load .cov and .cor output from a model run",
Long: covcorLongDescription,
Run: covcor,
Long: covcorLongDescription,
Run: covcor,
}

func covcor(cmd *cobra.Command, args []string) {
Expand All @@ -52,4 +53,4 @@ func covcor(cmd *cobra.Command, args []string) {
}
func init() {
nonmemCmd.AddCommand(covcorCmd)
}
}
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"regexp"
"strings"

"github.com/ghodss/yaml"
"bbi/configlib"
"github.com/ghodss/yaml"

"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/local.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cmd

import (
"bbi/configlib"
"crypto/md5"
"encoding/json"
"errors"
"fmt"
"bbi/configlib"
log "github.com/sirupsen/logrus"
"io"
"os/exec"
Expand Down
7 changes: 3 additions & 4 deletions cmd/nonmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ var nonmemLongDescription string = fmt.Sprintf("\n%s\n\n%s\n\n%s\n", runLongDesc
var nonmemCmd = &cobra.Command{
Use: "nonmem",
Short: "nonmem a (set of) models locally or on the grid",
Long: nonmemLongDescription,
Run: nonmem,
Long: nonmemLongDescription,
Run: nonmem,
}

func nonmem(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -272,7 +272,6 @@ func copyFileToDestination(l *NonMemModel, modifyPath bool) error {

//We'll use stats for setting the mode of the target file to make sure perms are the same


for k, line := range sourceLines {
if strings.Contains(line, "$DATA") {
sourceLines[k] = parser.AddPathLevelToData(line)
Expand Down Expand Up @@ -725,7 +724,7 @@ func NewNonMemModel(modelname string, config configlib.Config) (NonMemModel, err
lm.OriginalModel = lm.Model

f, e := utils.FileAndExt(lm.Model)
lm.FileName = f
lm.FileName = f
lm.Extension = strings.TrimPrefix(e, ".")

//Get the raw path of the original by stripping the actual file from it
Expand Down
66 changes: 33 additions & 33 deletions cmd/nonmem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"reflect"
"testing"

"github.com/google/uuid"
"bbi/configlib"
"github.com/google/uuid"
"github.com/spf13/afero"
)

Expand Down Expand Up @@ -79,22 +79,22 @@ func Test_processNMFEOptions(t *testing.T) {
name: "Normal Operation",
args: args{
config: configlib.Config{
NMVersion: "",
Overwrite: false,
CleanLvl: 0,
CopyLvl: 0,
Git: false,
BbiBinary: "",
SaveConfig: false,
OutputDir: "",
Threads: 0,
Debug: false,
Local: configlib.LocalDetail{},
Nonmem: nil,
Delay: 0,
NMQual: false,
JSON: false,
Logfile: "",
NMVersion: "",
Overwrite: false,
CleanLvl: 0,
CopyLvl: 0,
Git: false,
BbiBinary: "",
SaveConfig: false,
OutputDir: "",
Threads: 0,
Debug: false,
Local: configlib.LocalDetail{},
Nonmem: nil,
Delay: 0,
NMQual: false,
JSON: false,
Logfile: "",
NMFEOptions: configlib.NMFEOptions{
LicenseFile: "/tmp/nonmem.lic",
PRSame: false,
Expand All @@ -116,22 +116,22 @@ func Test_processNMFEOptions(t *testing.T) {
name: "All booleans, no text",
args: args{
config: configlib.Config{
NMVersion: "",
Overwrite: false,
CleanLvl: 0,
CopyLvl: 0,
Git: false,
BbiBinary: "",
SaveConfig: false,
OutputDir: "",
Threads: 0,
Debug: false,
Local: configlib.LocalDetail{},
Nonmem: nil,
Delay: 0,
NMQual: false,
JSON: false,
Logfile: "",
NMVersion: "",
Overwrite: false,
CleanLvl: 0,
CopyLvl: 0,
Git: false,
BbiBinary: "",
SaveConfig: false,
OutputDir: "",
Threads: 0,
Debug: false,
Local: configlib.LocalDetail{},
Nonmem: nil,
Delay: 0,
NMQual: false,
JSON: false,
Logfile: "",
NMFEOptions: configlib.NMFEOptions{
LicenseFile: "",
PRSame: true,
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
package cmd

import (
"bbi/configlib"
"fmt"
"github.com/metrumresearchgroup/turnstile"
log "github.com/sirupsen/logrus"
"github.com/spf13/afero"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
"io"
"math/rand"
"os"
"path"
"path/filepath"
"sync"
"time"
"bbi/configlib"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
)

// VERSION is the current bbi version
Expand Down
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cmd

import (
"bytes"
"bbi/configlib"
"bytes"
"github.com/metrumresearchgroup/turnstile"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -242,7 +242,7 @@ func ExecutePostWorkDirectivesWithEnvironment(worker PostWorkExecutor) (string,

environment, err := PostExecutionEnvironment(postworkConfig, postWorkEnv)

environment = append(environment,os.Environ()...)
environment = append(environment, os.Environ()...)

log.WithFields(log.Fields{
"environment": environment,
Expand Down
6 changes: 3 additions & 3 deletions cmd/sge.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cmd

import (
"bbi/utils"
"bytes"
"errors"
"bbi/utils"
log "github.com/sirupsen/logrus"
"os/exec"
"path"
Expand Down Expand Up @@ -288,7 +288,7 @@ func executeSGEJob(model *NonMemModel) turnstile.ConcurrentError {
}...)
}

qsubArguments = append(qsubArguments, filepath.Join(model.OutputDir,scriptName))
qsubArguments = append(qsubArguments, filepath.Join(model.OutputDir, scriptName))

if err != nil {
return newConcurrentError(model.Model, "Could not locate qsub binary in path", err)
Expand All @@ -305,7 +305,7 @@ func executeSGEJob(model *NonMemModel) turnstile.ConcurrentError {

if len(additionalEnvs) > 0 {
log.Debugf("Additional post work envs were provided. Total of %d", len(additionalEnvs))
command.Env = append(command.Env,additionalEnvs...)
command.Env = append(command.Env, additionalEnvs...)
}

output, err := command.CombinedOutput()
Expand Down
14 changes: 7 additions & 7 deletions cmd/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package cmd

import (
parser "bbi/parsers/nmparser"
"encoding/json"
"fmt"
parser "bbi/parsers/nmparser"
log "github.com/sirupsen/logrus"
"os"
"runtime"
Expand All @@ -33,6 +33,7 @@ var (
noShk bool
extFile string
)

const summaryLongDescription string = `summarize model(s), for example:
bbi nonmem summary run001/run001
bbi nonmem summary run001/run001.lst
Expand All @@ -43,8 +44,8 @@ bbi nonmem summary run001/run001.res
var summaryCmd = &cobra.Command{
Use: "summary",
Short: "summarize the output of model(s)",
Long: summaryLongDescription,
Run: summary,
Long: summaryLongDescription,
Run: summary,
}

type jsonResults struct {
Expand All @@ -57,7 +58,7 @@ func summary(cmd *cobra.Command, args []string) {
viper.Debug()
}
if len(args) == 1 {
results, err := parser.GetModelOutput(args[0], parser.NewModelOutputFile(extFile, noExt), !noGrd, !noShk, )
results, err := parser.GetModelOutput(args[0], parser.NewModelOutputFile(extFile, noExt), !noGrd, !noShk)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -102,7 +103,7 @@ func summary(cmd *cobra.Command, args []string) {
for w := 1; w <= workers; w++ {
go func(w int, modIndex <-chan int, results chan<- modelResult) {
for i := range modIndex {
r, err := parser.GetModelOutput(args[i], parser.NewModelOutputFile(extFile, noExt), !noGrd, !noShk, )
r, err := parser.GetModelOutput(args[i], parser.NewModelOutputFile(extFile, noExt), !noGrd, !noShk)
if err != nil {
results <- modelResult{
Index: i,
Expand Down Expand Up @@ -142,12 +143,11 @@ func summary(cmd *cobra.Command, args []string) {
return
}


// not json lets print all successful models first then any errors
for i, res := range modelResults.Results {
res.Summary()
// add some spacing between models
if i != len(modelResults.Results) -1 {
if i != len(modelResults.Results)-1 {
fmt.Println("")
fmt.Println("")
}
Expand Down
2 changes: 1 addition & 1 deletion configlib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Config struct {
Parafile string `mapstructure:"parafile" yaml:"parafile" json:"parafile,omitempty"`
PostWorkExecutable string `mapstructure:"post_work_executable" yaml:"post_work_executable" json:"post_work_executable,omitempty"`
postWorkExecEnvs []string `mapstructure:"additional_post_work_envs" yaml:"additional_post_work_envs" json:"additional_post_work_envs,omitempty"`
GridNamePrefix string `mapstructure:"grid_name_prefix" yaml:"grid_name_prefix" json:"grid_name_prefix,omitempty"`
GridNamePrefix string `mapstructure:"grid_name_prefix" yaml:"grid_name_prefix" json:"grid_name_prefix,omitempty"`
}

func (c *Config) GetPostWorkExecEnvs() []string {
Expand Down
27 changes: 0 additions & 27 deletions main.go

This file was deleted.

47 changes: 0 additions & 47 deletions notes.md

This file was deleted.

Loading

0 comments on commit 39ae868

Please sign in to comment.