-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows to configure and trigger a custom preprocessing child workflow to be handled by a different worker. This initial implementation requires both workers to have access to the same filesystem to share the package.
- Loading branch information
Showing
11 changed files
with
413 additions
and
40 deletions.
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
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` | ||
|
||
```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
Oops, something went wrong.