You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2023/02/01 14:58:53 UTC
[beam] branch master updated: Add support for templates in task hints (#25214)
This is an automated email from the ASF dual-hosted git repository.
damccorm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 7a6598f2c96 Add support for templates in task hints (#25214)
7a6598f2c96 is described below
commit 7a6598f2c96397dd47c69cc21600d778e395a0a5
Author: Timur Sultanov <ti...@akvelon.com>
AuthorDate: Wed Feb 1 18:58:45 2023 +0400
Add support for templates in task hints (#25214)
---
learning/tour-of-beam/backend/internal/fs_content/load.go | 6 +++++-
learning/tour-of-beam/backend/internal/fs_content/load_test.go | 2 +-
learning/tour-of-beam/backend/samples/api/get_unit_content.json | 2 +-
.../samples/learning-content/module 1/group/unit-challenge/hint1.md | 2 +-
.../samples/learning-content/module 1/unit-challenge/hint1.md | 2 +-
.../samples/learning-content/module 2/unit-challenge/hint1.md | 2 +-
6 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/learning/tour-of-beam/backend/internal/fs_content/load.go b/learning/tour-of-beam/backend/internal/fs_content/load.go
index b0e0a8bfab4..d871cf2bf7e 100644
--- a/learning/tour-of-beam/backend/internal/fs_content/load.go
+++ b/learning/tour-of-beam/backend/internal/fs_content/load.go
@@ -103,7 +103,11 @@ func collectUnit(infopath string, ctx *sdkContext) (unit *tob.Unit, err error) {
// Here we rely on that WalkDir entries are lexically sorted
case regexp.MustCompile(hintMdRegexp).MatchString(d.Name()):
- content, err := os.ReadFile(path)
+ templateSource, err := os.ReadFile(path)
+ if err != nil {
+ return err
+ }
+ content, err := processTemplate(templateSource, ctx.sdk)
if err != nil {
return err
}
diff --git a/learning/tour-of-beam/backend/internal/fs_content/load_test.go b/learning/tour-of-beam/backend/internal/fs_content/load_test.go
index 1e3948a38fc..b5327c2fb07 100644
--- a/learning/tour-of-beam/backend/internal/fs_content/load_test.go
+++ b/learning/tour-of-beam/backend/internal/fs_content/load_test.go
@@ -29,7 +29,7 @@ func getTaskNode(id string, sdk tob.Sdk) tob.Node {
Id: id, Title: "Challenge Name",
Description: "## Challenge description\n\nawesome description\n",
Hints: []string{
- "## Hint 1\n\nhint 1",
+ fmt.Sprintf("## Hint 1\n\nhint 1 %s", sdk),
"## Hint 2\n\nhint 2",
},
TaskSnippetId: fmt.Sprintf("TB_EXAMPLES_%s_ChallengeTask", sdk.StorageID()),
diff --git a/learning/tour-of-beam/backend/samples/api/get_unit_content.json b/learning/tour-of-beam/backend/samples/api/get_unit_content.json
index dc0c259a794..5e019a4f370 100644
--- a/learning/tour-of-beam/backend/samples/api/get_unit_content.json
+++ b/learning/tour-of-beam/backend/samples/api/get_unit_content.json
@@ -3,7 +3,7 @@
"title": "Challenge Name",
"description": "## Challenge description\n\nawesome description\n",
"hints" : [
- "## Hint 1\n\nhint 1",
+ "## Hint 1\n\nhint 1 python",
"## Hint 2\n\nhint 2"
],
"taskSnippetId": "TB_EXAMPLES_SDK_PYTHON_ChallengeTask",
diff --git a/learning/tour-of-beam/backend/samples/learning-content/module 1/group/unit-challenge/hint1.md b/learning/tour-of-beam/backend/samples/learning-content/module 1/group/unit-challenge/hint1.md
index 0d023e307f5..75ddfc777c1 100644
--- a/learning/tour-of-beam/backend/samples/learning-content/module 1/group/unit-challenge/hint1.md
+++ b/learning/tour-of-beam/backend/samples/learning-content/module 1/group/unit-challenge/hint1.md
@@ -1,3 +1,3 @@
## Hint 1
-hint 1
\ No newline at end of file
+hint 1 {{if (eq .Sdk "go")}}go{{end}}{{if (eq .Sdk "python")}}python{{end}}{{if (eq .Sdk "java")}}java{{end}}{{if (eq .Sdk "scio")}}scio{{end}}
\ No newline at end of file
diff --git a/learning/tour-of-beam/backend/samples/learning-content/module 1/unit-challenge/hint1.md b/learning/tour-of-beam/backend/samples/learning-content/module 1/unit-challenge/hint1.md
index 0d023e307f5..75ddfc777c1 100644
--- a/learning/tour-of-beam/backend/samples/learning-content/module 1/unit-challenge/hint1.md
+++ b/learning/tour-of-beam/backend/samples/learning-content/module 1/unit-challenge/hint1.md
@@ -1,3 +1,3 @@
## Hint 1
-hint 1
\ No newline at end of file
+hint 1 {{if (eq .Sdk "go")}}go{{end}}{{if (eq .Sdk "python")}}python{{end}}{{if (eq .Sdk "java")}}java{{end}}{{if (eq .Sdk "scio")}}scio{{end}}
\ No newline at end of file
diff --git a/learning/tour-of-beam/backend/samples/learning-content/module 2/unit-challenge/hint1.md b/learning/tour-of-beam/backend/samples/learning-content/module 2/unit-challenge/hint1.md
index 0d023e307f5..75ddfc777c1 100644
--- a/learning/tour-of-beam/backend/samples/learning-content/module 2/unit-challenge/hint1.md
+++ b/learning/tour-of-beam/backend/samples/learning-content/module 2/unit-challenge/hint1.md
@@ -1,3 +1,3 @@
## Hint 1
-hint 1
\ No newline at end of file
+hint 1 {{if (eq .Sdk "go")}}go{{end}}{{if (eq .Sdk "python")}}python{{end}}{{if (eq .Sdk "java")}}java{{end}}{{if (eq .Sdk "scio")}}scio{{end}}
\ No newline at end of file