Skip to content

Commit

Permalink
Replace remove files activity
Browse files Browse the repository at this point in the history
Replace "github.com/artefactual-sdps/remove-files-activity" with
"github.com/artefactual-sdps/temporal-activities/removefiles".

Also:
- Remove example ".remove" and ".succumb" files
- Remove creation of ".remove" file from kube dev overlay
  • Loading branch information
djjuhasz committed Apr 19, 2024
1 parent 403e998 commit f7c3e0e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 26 deletions.
1 change: 0 additions & 1 deletion .remove.example

This file was deleted.

1 change: 0 additions & 1 deletion .succumb.example

This file was deleted.

6 changes: 3 additions & 3 deletions cmd/worker/workercmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/artefactual-sdps/preprocessing-moma/internal/config"
"github.com/artefactual-sdps/preprocessing-moma/internal/workflow"
remove "github.com/artefactual-sdps/remove-files-activity"
"github.com/artefactual-sdps/temporal-activities/removefiles"
)

const Name = "preprocessing-worker"
Expand Down Expand Up @@ -58,8 +58,8 @@ func (m *Main) Run(ctx context.Context) error {
temporalsdk_workflow.RegisterOptions{Name: m.cfg.Temporal.WorkflowName},
)
w.RegisterActivityWithOptions(
remove.NewRemoveFilesActivity().Execute,
temporalsdk_activity.RegisterOptions{Name: remove.RemoveFilesName},
removefiles.NewActivity(m.cfg.RemoveFiles).Execute,
temporalsdk_activity.RegisterOptions{Name: removefiles.ActivityName},
)

if err := w.Start(); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/artefactual-sdps/preprocessing-moma
go 1.22.2

require (
github.com/artefactual-sdps/remove-files-activity v0.0.0-20240301164716-575fb8b7b834
github.com/artefactual-sdps/temporal-activities v0.0.0-20240418211119-e97b26fed41b
github.com/go-logr/logr v1.4.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
Expand All @@ -13,7 +13,6 @@ require (
)

require (
github.com/Diogenesoftoronto/go-gitignore v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Diogenesoftoronto/go-gitignore v1.1.0 h1:G8jh5GxjmCidSTvotSiNeBMxMLma9zOtjb2wZ/QvLk8=
github.com/Diogenesoftoronto/go-gitignore v1.1.0/go.mod h1:mmVD39ljrmsXQECsd829osXfYy+nzbxqYEH2rCLE+XA=
github.com/artefactual-sdps/remove-files-activity v0.0.0-20240301164716-575fb8b7b834 h1:EJzGpWDLTrx/FbXfwewHqXsGeIihz1CyKTjCdAO67mU=
github.com/artefactual-sdps/remove-files-activity v0.0.0-20240301164716-575fb8b7b834/go.mod h1:5U5uQ147WRiusG3LMDopp9MOZEcOJ649TUnccLefhKU=
github.com/artefactual-sdps/temporal-activities v0.0.0-20240418211119-e97b26fed41b h1:gfScS2NGX6STL9BkTuuDkCp9/f4PUqG4QITbsTKyuJA=
github.com/artefactual-sdps/temporal-activities v0.0.0-20240418211119-e97b26fed41b/go.mod h1:oviveqOfixKKhUlNYb/gRq/NceVLdseOB/GUK8Rinfk=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down
5 changes: 3 additions & 2 deletions hack/kube/overlays/dev/preprocessing-moma-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ stringData:
[worker]
maxConcurrentSessions = 1
.remove: |
.DS_Store
[removefiles]
removeNames = ".DS_Store"
5 changes: 4 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/artefactual-sdps/temporal-activities/removefiles"
"github.com/spf13/viper"
)

Expand All @@ -12,11 +13,13 @@ type ConfigurationValidator interface {
}

type Configuration struct {
Verbosity int
Debug bool
Verbosity int
SharedPath string
Temporal Temporal
Worker WorkerConfig

RemoveFiles removefiles.Config
}

type Temporal struct {
Expand Down
21 changes: 21 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import (

const testConfig = `# Config
debug = true
verbosity = 2
sharedPath = "/tmp"
[temporal]
address = "host:port"
namespace = "default"
taskQueue = "preprocessing"
workflowName = "preprocessing"
[worker]
maxConcurrentSessions = 1
[removefiles]
removeNames = ".DS_Store, Thumbs.db"
`

func TestConfig(t *testing.T) {
Expand All @@ -31,5 +40,17 @@ func TestConfig(t *testing.T) {
assert.NilError(t, err)
assert.Equal(t, found, true)
assert.Equal(t, configFileUsed, configFile)

assert.Equal(t, c.Debug, true)
assert.Equal(t, c.Verbosity, 2)
assert.Equal(t, c.SharedPath, "/tmp")

assert.Equal(t, c.Temporal.Address, "host:port")
assert.Equal(t, c.Temporal.Namespace, "default")
assert.Equal(t, c.Temporal.TaskQueue, "preprocessing")
assert.Equal(t, c.Temporal.WorkflowName, "preprocessing")

assert.Equal(t, c.Worker.MaxConcurrentSessions, 1)

assert.Equal(t, c.RemoveFiles.RemoveNames, ".DS_Store, Thumbs.db")
}
20 changes: 8 additions & 12 deletions internal/workflow/preprocessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"path/filepath"
"time"

"github.com/artefactual-sdps/preprocessing-moma/internal/activities"
remove "github.com/artefactual-sdps/remove-files-activity"
"github.com/artefactual-sdps/temporal-activities/removefiles"
"go.artefactual.dev/tools/temporal"
temporalsdk_temporal "go.temporal.io/sdk/temporal"
temporalsdk_workflow "go.temporal.io/sdk/workflow"
Expand Down Expand Up @@ -44,16 +43,13 @@ func (w *PreprocessingWorkflow) Execute(

localPath := filepath.Join(w.sharedPath, filepath.Clean(params.RelativePath))

// TODO Make the file path a part of the enduro config or check the configuration later.
// A remove file works like a .gitignore file.
removePath := "/home/preprocessing-moma/.config/.remove"

// Remove hidden files.
var removedPaths activities.RemovePathsResult
e = temporalsdk_workflow.ExecuteActivity(withLocalActOpts(ctx), remove.RemoveFilesName, &remove.RemoveFilesParams{
RemovePath: localPath,
IgnorePath: removePath,
}).Get(ctx, &removedPaths)
// Remove unwanted files.
var removeFilesResult removefiles.ActivityResult
e = temporalsdk_workflow.ExecuteActivity(
withLocalActOpts(ctx),
removefiles.ActivityName,
&removefiles.ActivityParams{Path: localPath},
).Get(ctx, &removeFilesResult)
if e != nil {
return nil, e
}
Expand Down

0 comments on commit f7c3e0e

Please sign in to comment.