-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add preprocessing child workflow #861
Merged
jraddaoui
merged 1 commit into
artefactual-sdps:main
from
artefactual-sdps:dev/preprocessing-child-workflow
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,14 @@ are planning to use Archivematica as preservation system. | |
Build and use a local version of a3m. Requires to have the `a3m` repository | ||
cloned as a sibling of this repository folder. | ||
|
||
### PREPROCESSING_PATH | ||
|
||
Relative path to a preprocessing child workflow repository. It loads a Tiltfile | ||
called `Tiltfile.enduro` from that repository and mounts a presistent volume | ||
claim (PVC) in the preservation system pod. That PVC must be defined in the | ||
preprocessing and be called `preprocessing-pvc`. Check the [Preprocessing child | ||
workflow] docs to configure the child workflow execution. | ||
|
||
Comment on lines
+195
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be better documented (if it's still needed) in a |
||
## Tilt UI helpers | ||
|
||
### Upload to Minio | ||
|
@@ -259,3 +267,4 @@ is sometimes not setup properly. To solve it, from the Tilt UI, restart the | |
[visual studio code]: https://code.visualstudio.com/ | ||
[working with archivematica]: archivematica.md | ||
[devbox]: https://www.jetpack.io/devbox/docs/quickstart/#install-devbox | ||
[preprocessing child workflow]: preprocessing.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Preprocessing child workflow | ||
|
||
The processing workflow can be extended with the execution of a preprocessing | ||
child workflow. | ||
|
||
## Configuration | ||
|
||
### `.tilt.env` | ||
|
||
Check the [Tilt environment configuration]. | ||
|
||
### `enduro.toml` | ||
|
||
djjuhasz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```toml | ||
# Optional preprocessing child workflow configuration. | ||
[preprocessing] | ||
# enabled triggers the execution of the child workflow, when set to false all other | ||
# options are ignored. | ||
enabled = true | ||
# extract determines if the package extraction happens on the child workflow. | ||
extract = false | ||
# sharedPath is the full path to the directory used to share the package between workflows, | ||
# required when enabled is set to true. | ||
sharedPath = "/home/enduro/preprocessing" | ||
|
||
# Temporal configuration to trigger the preprocessing child workflow, all fields are | ||
# required when enabled is set to true. | ||
[preprocessing.temporal] | ||
namespace = "default" | ||
taskQueue = "preprocessing" | ||
workflowName = "preprocessing" | ||
``` | ||
|
||
[tilt environment configuration]: devel.md#preprocessing_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package preprocessing | ||
|
||
import "errors" | ||
|
||
type Config struct { | ||
// Enable preprocessing child workflow. | ||
Enabled bool | ||
// Extract package in preprocessing. | ||
Extract bool | ||
// Local path shared between workers. | ||
SharedPath string | ||
// Temporal configuration. | ||
Temporal Temporal | ||
} | ||
|
||
type Temporal struct { | ||
Namespace string | ||
TaskQueue string | ||
WorkflowName string | ||
} | ||
|
||
type WorkflowParams struct { | ||
// Relative path to the shared path. | ||
RelativePath string | ||
} | ||
|
||
type WorkflowResult struct { | ||
// Relative path to the shared path. | ||
RelativePath string | ||
} | ||
|
||
// Validate implements config.ConfigurationValidator. | ||
func (c Config) Validate() error { | ||
if !c.Enabled { | ||
return nil | ||
} | ||
if c.SharedPath == "" { | ||
return errors.New("sharedPath is required in the [preprocessing] configuration") | ||
} | ||
if c.Temporal.Namespace == "" || c.Temporal.TaskQueue == "" || c.Temporal.WorkflowName == "" { | ||
return errors.New( | ||
"namespace, taskQueue and workflowName are required in the [preprocessing.temporal] configuration", | ||
) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package preprocessing_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
|
||
"github.com/artefactual-sdps/enduro/internal/preprocessing" | ||
) | ||
|
||
func TestPreprocessingConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
type test struct { | ||
name string | ||
config preprocessing.Config | ||
wantErr string | ||
} | ||
for _, tt := range []test{ | ||
{ | ||
name: "Validates if not enabled", | ||
config: preprocessing.Config{ | ||
Enabled: false, | ||
}, | ||
}, | ||
{ | ||
name: "Validates with all required fields", | ||
config: preprocessing.Config{ | ||
Enabled: true, | ||
SharedPath: "/tmp", | ||
Temporal: preprocessing.Temporal{ | ||
Namespace: "default", | ||
TaskQueue: "preprocessing", | ||
WorkflowName: "preprocessing", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Returns error if shared path is missing", | ||
config: preprocessing.Config{ | ||
Enabled: true, | ||
}, | ||
wantErr: "sharedPath is required in the [preprocessing] configuration", | ||
}, | ||
{ | ||
name: "Returns error if temporal config is missing", | ||
config: preprocessing.Config{ | ||
Enabled: true, | ||
SharedPath: "/tmp", | ||
}, | ||
wantErr: "namespace, taskQueue and workflowName are required in the [preprocessing.temporal] configuration", | ||
}, | ||
} { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
err := tt.config.Validate() | ||
if tt.wantErr != "" { | ||
assert.Error(t, err, tt.wantErr) | ||
return | ||
} | ||
assert.NilError(t, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,9 @@ type DownloadActivity struct { | |
} | ||
|
||
type DownloadActivityParams struct { | ||
Key string | ||
WatcherName string | ||
Key string | ||
WatcherName string | ||
DestinationPath string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check #926 for more info. |
||
} | ||
|
||
type DownloadActivityResult struct { | ||
|
@@ -47,7 +48,7 @@ func (a *DownloadActivity) Execute( | |
"WatcherName", params.WatcherName, | ||
) | ||
|
||
destDir, err := os.MkdirTemp("", "enduro") | ||
destDir, err := os.MkdirTemp(params.DestinationPath, "enduro") | ||
if err != nil { | ||
return &DownloadActivityResult{}, temporal_tools.NewNonRetryableError(fmt.Errorf("make temp dir: %v", err)) | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to make the
claimName
andmountPath
configurable through the environment, but I don't like this solution in general. I'll try to find something better while working on the remote option, maybe just working with the k8s manifests, ideas are welcome.