Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 authored Oct 7, 2024
2 parents 1718725 + d6d0517 commit a3f0d2c
Show file tree
Hide file tree
Showing 36 changed files with 2,576 additions and 3,345 deletions.
4 changes: 2 additions & 2 deletions cmd/run/parse_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package run
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -197,7 +197,7 @@ func valsToTask(vals flagVals) (task *tes.Task, err error) {
}

func getContent(p string) string {
b, err := ioutil.ReadFile(p)
b, err := os.ReadFile(p)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/util/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -42,7 +41,7 @@ func MergeConfigFileWithFlags(file string, flagConf config.Config) (config.Confi
// - "path" is the path of the file.
// - "cleanup" can be called to remove the temporary file.
func TempConfigFile(c config.Config, name string) (path string, cleanup func()) {
tmpdir, err := ioutil.TempDir("", "")
tmpdir, err := os.MkdirTemp("", "")
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/util/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package util
import (
"bytes"
"io"
"io/ioutil"
"os"
)

// EmptyReader returns an io.Reader which is empty and immediately closed.
func EmptyReader() io.Reader {
return ioutil.NopCloser(bytes.NewReader(nil))
return io.NopCloser(bytes.NewReader(nil))
}

// StdinPipe will return stdin if it's available, otherwise it will return
Expand Down
4 changes: 2 additions & 2 deletions compute/gridengine/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gridengine

import (
"fmt"
"io/ioutil"
"os"
"regexp"

"github.com/ohsu-comp-bio/funnel/compute"
Expand All @@ -16,7 +16,7 @@ import (
// NewBackend returns a new Grid Engine HPCBackend instance.
func NewBackend(conf config.Config, reader tes.ReadOnlyServer, writer events.Writer, log *logger.Logger) (*compute.HPCBackend, error) {
if conf.GridEngine.TemplateFile != "" {
content, err := ioutil.ReadFile(conf.GridEngine.TemplateFile)
content, err := os.ReadFile(conf.GridEngine.TemplateFile)
if err != nil {
return nil, fmt.Errorf("reading template: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions compute/hpc_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package compute
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/ohsu-comp-bio/funnel/config"
"github.com/ohsu-comp-bio/funnel/tes"
)

func TestSetupTemplatedHPCSubmit(t *testing.T) {
tmp, err := ioutil.TempDir("", "funnel-test-scheduler")
tmp, err := os.MkdirTemp("", "funnel-test-scheduler")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -64,7 +64,7 @@ funnel worker run --taskID {{.TaskId}}
t.Fatal(err)
}

actual, rerr := ioutil.ReadFile(sf)
actual, rerr := os.ReadFile(sf)
if rerr != nil {
t.Fatal(rerr)
}
Expand Down
4 changes: 2 additions & 2 deletions compute/htcondor/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
Expand All @@ -21,7 +21,7 @@ import (
// NewBackend returns a new HTCondor backend instance.
func NewBackend(ctx context.Context, conf config.Config, reader tes.ReadOnlyServer, writer events.Writer, log *logger.Logger) (*compute.HPCBackend, error) {
if conf.HTCondor.TemplateFile != "" {
content, err := ioutil.ReadFile(conf.HTCondor.TemplateFile)
content, err := os.ReadFile(conf.HTCondor.TemplateFile)
if err != nil {
return nil, fmt.Errorf("reading template: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions compute/kubernetes/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"text/template"
"time"

Expand All @@ -28,7 +28,7 @@ import (
// NewBackend returns a new local Backend instance.
func NewBackend(ctx context.Context, conf config.Kubernetes, reader tes.ReadOnlyServer, writer events.Writer, log *logger.Logger) (*Backend, error) {
if conf.TemplateFile != "" {
content, err := ioutil.ReadFile(conf.TemplateFile)
content, err := os.ReadFile(conf.TemplateFile)
if err != nil {
return nil, fmt.Errorf("reading template: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions compute/pbs/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/xml"
"fmt"
"io/ioutil"
"os"
"os/exec"
"time"

Expand All @@ -19,7 +19,7 @@ import (
// NewBackend returns a new PBS (Portable Batch System) HPCBackend instance.
func NewBackend(ctx context.Context, conf config.Config, reader tes.ReadOnlyServer, writer events.Writer, log *logger.Logger) (*compute.HPCBackend, error) {
if conf.PBS.TemplateFile != "" {
content, err := ioutil.ReadFile(conf.PBS.TemplateFile)
content, err := os.ReadFile(conf.PBS.TemplateFile)
if err != nil {
return nil, fmt.Errorf("reading template: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions compute/scheduler/testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scheduler
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"
"time"

Expand All @@ -21,7 +21,7 @@ type testNode struct {
}

func newTestNode(conf config.Config, t *testing.T) testNode {
workDir, _ := ioutil.TempDir("", "funnel-test-storage-")
workDir, _ := os.MkdirTemp("", "funnel-test-storage-")
conf.Worker.WorkDir = workDir
log := logger.NewLogger("test-node", logger.DebugConfig())

Expand Down
4 changes: 2 additions & 2 deletions compute/slurm/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strings"
Expand All @@ -22,7 +22,7 @@ import (
// NewBackend returns a new Slurm HPCBackend instance.
func NewBackend(ctx context.Context, conf config.Config, reader tes.ReadOnlyServer, writer events.Writer, log *logger.Logger) (*compute.HPCBackend, error) {
if conf.Slurm.TemplateFile != "" {
content, err := ioutil.ReadFile(conf.Slurm.TemplateFile)
content, err := os.ReadFile(conf.Slurm.TemplateFile)
if err != nil {
return nil, fmt.Errorf("reading template: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions config/gce/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gce
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -101,7 +101,7 @@ func LoadMetadataFromURL(url string) (*Metadata, error) {
return nil, fmt.Errorf("Non-200 response status from GCE Metadata: %d", resp.StatusCode)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions config/gce/meta_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package gce

import (
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"os"
"testing"

"github.com/ohsu-comp-bio/funnel/config"
)

func loadTestData(name string) []byte {
b, err := ioutil.ReadFile(name + ".json")
b, err := os.ReadFile(name + ".json")
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions config/internal/bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
Expand All @@ -22,7 +22,7 @@ func ToYamlFile(c Config, path string) error {
if err != nil {
return err
}
return ioutil.WriteFile(path, b, 0600)
return os.WriteFile(path, b, 0600)
}

// Parse parses a YAML doc into the given Config instance.
Expand Down Expand Up @@ -56,7 +56,7 @@ func ParseFile(relpath string, conf *Config) error {
}

// Read file
source, err := ioutil.ReadFile(path)
source, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("failed to read config at path %s: \n%v", path, err)
}
Expand Down
3 changes: 1 addition & 2 deletions examples/internal/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -398,7 +397,7 @@ func RestoreAsset(dir, name string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
err = os.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package logger
import (
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"strings"
Expand Down Expand Up @@ -74,7 +73,7 @@ func (l *Logger) SetOutput(o io.Writer) {

// Discard configures the logger to discard all logs.
func (l *Logger) Discard() {
l.SetOutput(ioutil.Discard)
l.SetOutput(io.Discard)
}

// Debug logs a debug message.
Expand Down
3 changes: 1 addition & 2 deletions storage/amazon_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/md5"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -59,7 +58,7 @@ func NewAmazonS3(conf config.AmazonS3Storage) (*AmazonS3, error) {
}

if conf.SSE.CustomerKeyFile != "" {
key, err := ioutil.ReadFile(conf.SSE.CustomerKeyFile)
key, err := os.ReadFile(conf.SSE.CustomerKeyFile)
if err != nil {
return nil, fmt.Errorf("error reading sse-c file: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions storage/google_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -34,7 +33,7 @@ func NewGoogleCloud(conf config.GoogleCloudStorage) (*GoogleCloud, error) {
if conf.CredentialsFile != "" {
// Pull the client configuration (e.g. auth) from a given account file.
// This is likely downloaded from Google Cloud manually via IAM & Admin > Service accounts.
bytes, rerr := ioutil.ReadFile(conf.CredentialsFile)
bytes, rerr := os.ReadFile(conf.CredentialsFile)
if rerr != nil {
return nil, rerr
}
Expand Down
13 changes: 5 additions & 8 deletions storage/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,16 @@ func copyFile(ctx context.Context, source string, dest string) (err error) {

// Hard links file source to destination dest.
func linkFile(ctx context.Context, source string, dest string) error {

// If source has a glob or wildcard, get the filepath using the filepath.Glob function
if strings.Contains(source, "*") {
globs, err := filepath.Glob(source)
if err != nil {
return fmt.Errorf("failed to get filepath using Glob: %v", err)
}
for _, glob := range globs {
// Since tesOutput.path contains a wildcard, then the dest path must be a directory
// Ref: https://github.com/ga4gh/task-execution-schemas/blob/v1.1/openapi/task_execution_service.openapi.yaml#L528
// TODO: Verify that path_prefix is being removed from the dest filepath
dest = filepath.Join(dest, filepath.Base(glob))
err := processItem(ctx, glob, dest)
// Correctly calculate the destination for each file
destFile := filepath.Join(dest, filepath.Base(glob))
err := processItem(ctx, glob, destFile)
if err != nil {
return err
}
Expand All @@ -192,7 +189,7 @@ func linkFile(ctx context.Context, source string, dest string) error {
}

// Process a single item (file or directory)
func processItem(ctx context.Context, source string, dest string) error {
func processItem(ctx context.Context, source, dest string) error {
fileInfo, err := os.Stat(source)
if err != nil {
return err
Expand All @@ -206,7 +203,7 @@ func processItem(ctx context.Context, source string, dest string) error {
}

// Process a directory
func processDirectory(ctx context.Context, source string, dest string) error {
func processDirectory(ctx context.Context, source, dest string) error {
// Create destination directory
err := os.MkdirAll(dest, 0755) // Adjust permissions as needed
if err != nil {
Expand Down
Loading

0 comments on commit a3f0d2c

Please sign in to comment.