Skip to content

Commit

Permalink
Mark YamlTemplate as GA
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Kinard <jeff@thekinards.com>
  • Loading branch information
Polber committed May 7, 2024
1 parent 92a6433 commit 0a1ea0d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public static String readmeMarkdown(ImageSpec imageSpec) throws IOException, Tem
parameters.put("flex", imageSpec.getMetadata().isFlexTemplate());
parameters.put("statics", BeansWrapper.getDefaultInstance().getStaticModels());
parameters.put("language", imageSpec.getSdkInfo().getLanguage());
parameters.put(
"appendTemplate",
!imageSpec
.getMetadata()
.getName()
.substring(Math.max(0, imageSpec.getMetadata().getName().length() - 8))
.equalsIgnoreCase("template"));

Template template = freemarkerConfig.getTemplate("README-template.md");

Expand Down Expand Up @@ -78,6 +85,13 @@ public static String siteMarkdown(ImageSpec imageSpec) throws IOException, Templ
parameters.put("flex", imageSpec.getMetadata().isFlexTemplate());
parameters.put("statics", BeansWrapper.getDefaultInstance().getStaticModels());
parameters.put("base_include", "dataflow");
parameters.put(
"appendTemplate",
!imageSpec
.getMetadata()
.getName()
.substring(Math.max(0, imageSpec.getMetadata().getName().length() - 8))
.equalsIgnoreCase("template"));

Template template = freemarkerConfig.getTemplate("site-template.md");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ public ImageSpec buildSpecModel(boolean validateFlag) {
block.name(), Arrays.asList(block.content())))
.collect(Collectors.toList()));

if (templateAnnotation.type().equals(TemplateType.YAML)) {
metadata.setMainClass("");
} else if (templateAnnotation.placeholderClass() != null
if (templateAnnotation.placeholderClass() != null
&& templateAnnotation.placeholderClass() != void.class) {
metadata.setMainClass(templateAnnotation.placeholderClass().getName());
} else {
Expand Down
4 changes: 2 additions & 2 deletions plugins/core-plugin/src/main/resources/README-template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#assign TemplateDocsUtils=statics['com.google.cloud.teleport.plugin.docs.TemplateDocsUtils']>

${spec.metadata.name} template
${spec.metadata.name}<#if appendTemplate> template</#if>
---
<#list spec.metadata.description?split("\n\n") as paragraph>
${TemplateDocsUtils.wrapText(paragraph!?trim, 80, "", false)?ensure_ends_with(".")}
Expand Down Expand Up @@ -95,7 +95,7 @@ mvn clean package -PtemplatesStage \
-DbucketName="$BUCKET_NAME" \
-DstagePrefix="templates" \
-DtemplateName="${spec.metadata.internalName}" \
<#if language == 'PYTHON'>
<#if language == 'PYTHON' || language == 'YAML'>
-f python
<#elseif flex>
-f v2/${spec.metadata.module!}
Expand Down
4 changes: 2 additions & 2 deletions plugins/core-plugin/src/main/resources/site-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{% extends "${base_include}/_base.html" %}
{% include "${base_include}/_local_variables.html" %}
{% include "${base_include}/docs/guides/templates/_provided-templates-vars.html" %}
{% block page_title %}${TemplateDocsUtils.replaceVariableInterpolationNames(spec.metadata.name)} template{% endblock %}
{% block page_title %}${TemplateDocsUtils.replaceVariableInterpolationNames(spec.metadata.name)}<#if appendTemplate> template</#if>{% endblock %}

{% block body %}

<section id="${spec.metadata.internalName?lower_case?replace("_", "")}">

{% dynamic setvar launch_name %}the <b>${TemplateDocsUtils.replaceVariableInterpolationNames(spec.metadata.name)}</b> template{% dynamic endsetvar %}
{% dynamic setvar launch_name %}the <b>${TemplateDocsUtils.replaceVariableInterpolationNames(spec.metadata.name)}</b><#if appendTemplate> template</#if>{% dynamic endsetvar %}
{% dynamic setvar gcs_template_name %}${spec.metadata.internalName}{% dynamic endsetvar %}
<#if spec.metadata.preview!false>
{% dynamic setvar launch_stage %}beta{% dynamic endsetvar %}
Expand Down
23 changes: 17 additions & 6 deletions python/README_Yaml_Template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

YAML Template (Experimental) template
YAML Template
---
YAML pipeline. Reads YAML from Cloud Storage and dynamically expands YAML into
Beam pipeline graph.
The YAML Template is used to run Dataflow pipelines written in Beam YAML. The
YAML pipeline can be passed to the template directly as a raw string or the
location of a Beam YAML pipeline file stored in Google Cloud Storage can
optionally be passed.
For launching a Beam YAML pipeline directly from the gcloud command line, see
https://cloud.google.com/sdk/gcloud/reference/beta/dataflow/yaml
For more information on Beam YAML, see
https://beam.apache.org/documentation/sdks/yaml/.



Expand All @@ -19,6 +25,7 @@ on [Metadata Annotations](https://github.com/GoogleCloudPlatform/DataflowTemplat

* **yaml_pipeline** : A yaml description of the pipeline to run.
* **yaml_pipeline_file** : A file in Cloud Storage containing a yaml description of the pipeline to run.
* **jinja_variables** : A json dict of variables used when invoking the jinja preprocessor on the provided yaml pipeline.



Expand Down Expand Up @@ -101,13 +108,15 @@ export TEMPLATE_SPEC_GCSPATH="gs://$BUCKET_NAME/templates/flex/Yaml_Template"
### Optional
export YAML_PIPELINE=<yaml_pipeline>
export YAML_PIPELINE_FILE=<yaml_pipeline_file>
export JINJA_VARIABLES=<jinja_variables>

gcloud dataflow flex-template run "yaml-template-job" \
--project "$PROJECT" \
--region "$REGION" \
--template-file-gcs-location "$TEMPLATE_SPEC_GCSPATH" \
--parameters "yaml_pipeline=$YAML_PIPELINE" \
--parameters "yaml_pipeline_file=$YAML_PIPELINE_FILE"
--parameters "yaml_pipeline_file=$YAML_PIPELINE_FILE" \
--parameters "jinja_variables=$JINJA_VARIABLES"
```

For more information about the command, please check:
Expand All @@ -130,6 +139,7 @@ export REGION=us-central1
### Optional
export YAML_PIPELINE=<yaml_pipeline>
export YAML_PIPELINE_FILE=<yaml_pipeline_file>
export JINJA_VARIABLES=<jinja_variables>

mvn clean package -PtemplatesRun \
-DskipTests \
Expand All @@ -138,8 +148,8 @@ mvn clean package -PtemplatesRun \
-Dregion="$REGION" \
-DjobName="yaml-template-job" \
-DtemplateName="Yaml_Template" \
-Dparameters="yaml_pipeline=$YAML_PIPELINE,yaml_pipeline_file=$YAML_PIPELINE_FILE" \
-f python
-Dparameters="yaml_pipeline=$YAML_PIPELINE,yaml_pipeline_file=$YAML_PIPELINE_FILE,jinja_variables=$JINJA_VARIABLES" \
-f v2/python
```

## Terraform
Expand Down Expand Up @@ -185,6 +195,7 @@ resource "google_dataflow_flex_template_job" "yaml_template" {
parameters = {
# yaml_pipeline = "<yaml_pipeline>"
# yaml_pipeline_file = "<yaml_pipeline_file>"
# jinja_variables = "<jinja_variables>"
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@
name = "Yaml_Template",
category = TemplateCategory.GET_STARTED,
type = Template.TemplateType.YAML,
displayName = "YAML Template (Experimental)",
displayName = "YAML Template",
description =
"YAML pipeline. Reads YAML from Cloud Storage and dynamically expands YAML into "
+ "Beam pipeline graph.",
"The YAML Template is used to run Dataflow pipelines written in Beam YAML. "
+ "The YAML pipeline can be passed to the template directly as a raw string or the location of a Beam YAML "
+ "pipeline file stored in Google Cloud Storage can optionally be passed."
+ "\n"
+ "For launching a Beam YAML pipeline directly from the gcloud command line, see "
+ "https://cloud.google.com/sdk/gcloud/reference/dataflow/yaml"
+ "\n"
+ "For more information on Beam YAML, see https://beam.apache.org/documentation/sdks/yaml/",
flexContainerName = "yaml-template",
contactInformation = "https://cloud.google.com/support")
contactInformation = "https://cloud.google.com/support",
requirements = {
"A valid Beam YAML pipeline.",
})
public interface YAMLTemplate {
@TemplateParameter.Text(
order = 1,
Expand Down

0 comments on commit 0a1ea0d

Please sign in to comment.