-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-13307][Playground] Support Python SDK #16050
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
Merged
pabloem
merged 26 commits into
apache:master
from
akvelon:BEAM-13307-playground-python-sdk
Nov 29, 2021
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b73f5f7
[Playground][BEAM-12941][Bugfix] Fix workflows for playground applica…
snkalinin d449275
Revert "[Playground][BEAM-12941][Bugfix] Fix workflows for playground…
ilya-kozyrev 69d0191
Merge branch 'apache:master' into master
ilya-kozyrev 1bf7f6f
Merge branch 'apache:master' into master
72bad55
Merge branch 'apache:master' into master
ilya-kozyrev 1d6783e
Merge branch 'apache:master' into master
3a81f54
Merge branch 'apache:master' into master
ilya-kozyrev d9cce13
Merge branch 'apache:master' into master
c24b695
Merge branch 'apache:master' into master
6b6f0b9
draft
10e7762
Merge branch 'apache:master' into master
24ef6bf
Merge branch 'apache:master' into master
pavel-avilov df5e053
Rename LF executable -> source
6b7603d
Reanme LF compile -> executables
f0b508b
Merge remote-tracking branch 'origin/BEAM-13297-refactoring-ls' into …
2957ff2
working python sdk
f240b10
Update playground/backend/internal/fs_tool/python_fs_test.go
05878a7
Update playground/backend/internal/fs_tool/python_fs_test.go
ab58327
Merge branch 'apache:master' into master
d8639b9
Merge branch 'master' into BEAM-13258-playground-python-sdk
02412f8
refactoring + adding dockerfile
302cb1f
Merge branch 'apache:master' into master
ElessarST 816d46c
add preparators array (will be filled later)
f44869a
Merge branch 'master' into BEAM-13307-playground-python-sdk
2b7569c
fix indentation
42a47e9
[BEAM-13307][Playground]
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 hidden or 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 hidden or 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,6 @@ | ||
| { | ||
| "compile_cmd": "", | ||
| "run_cmd": "python3", | ||
| "compile_args": [], | ||
| "run_args": [] | ||
| } | ||
This file contains hidden or 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,51 @@ | ||
| ############################################################################### | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ############################################################################### | ||
| ARG BASE_IMAGE=apache/beam_python3.7_sdk:latest | ||
| ARG GO_BASE_IMAGE=golang:1.17-buster | ||
| FROM $GO_BASE_IMAGE AS build | ||
|
|
||
| # Setup Go Environment | ||
| ENV GOPATH /go | ||
| ENV PATH $GOPATH/bin:$PATH | ||
| RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
| RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 &&\ | ||
| go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1 | ||
|
|
||
| # Prepare Application | ||
| COPY src /go/src/playground/backend | ||
| #COPY playground /go/src/playground/playground | ||
|
Member
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. remove this line? |
||
| WORKDIR /go/src/playground/backend | ||
| RUN ls | ||
| # Build Application | ||
| RUN go mod download &&\ | ||
| go mod tidy &&\ | ||
| cd cmd/server &&\ | ||
| go build -o /go/bin/server_python_backend | ||
|
|
||
| FROM $BASE_IMAGE | ||
| ENV SERVER_IP=0.0.0.0 | ||
| ENV SERVER_PORT=8080 | ||
| ENV APP_WORK_DIR=/opt/playground/backend/ | ||
| ENV BEAM_SDK="SDK_PYTHON" | ||
|
|
||
| # Copy build result | ||
| COPY --from=build /go/bin/server_python_backend /opt/playground/backend/ | ||
| COPY --from=build /go/src/playground/backend/configs /opt/playground/backend/configs/ | ||
|
|
||
| RUN printenv | ||
| ENTRYPOINT ["/opt/playground/backend/server_python_backend"] | ||
This file contains hidden or 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,22 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * License); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an AS IS BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| service: backend-python | ||
| runtime: custom | ||
| env: flex | ||
| manual_scaling: | ||
| instances: 1 |
This file contains hidden or 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,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * License); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an AS IS BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
|
|
||
| apply plugin: 'org.apache.beam.module' | ||
| apply plugin: 'base' | ||
| applyDockerNature() | ||
|
|
||
| def playgroundJobServerProject = "${project.path.replace('-container', '')}" | ||
|
|
||
| description = project(playgroundJobServerProject).description + " :: Container" | ||
|
|
||
| configurations { | ||
| dockerDependency | ||
| } | ||
|
|
||
| dependencies { | ||
| dockerDependency project(path: playgroundJobServerProject, configuration: "shadow") | ||
| } | ||
|
|
||
| task copyDockerfileDependencies(type: Copy) { | ||
| copy { | ||
| from '../../../backend/' | ||
| into 'build/src' | ||
| exclude 'containers' | ||
| } | ||
| copy { | ||
| from 'Dockerfile' | ||
| into 'build/' | ||
| } | ||
| copy { | ||
| from '../../../playground' | ||
| into 'build/playground' | ||
| } | ||
| } | ||
|
|
||
| docker { | ||
| name containerImageName( | ||
| name: project.docker_image_default_repo_prefix + "playground-backend-python", | ||
| root: project.rootProject.hasProperty(["docker-repository-root"]) ? | ||
| project.rootProject["docker-repository-root"] : | ||
| project.docker_image_default_repo_root) | ||
| files "./build/" | ||
| tags containerImageTags() | ||
| buildArgs(['BASE_IMAGE': project.rootProject.hasProperty(["base-image"]) ? | ||
| project.rootProject["base-image"] : | ||
| "apache/beam_python3.7_sdk" ]) | ||
|
Member
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. let's also document the places where the Beam container version is chosen in the README (also for later) |
||
| buildArgs(['GO_BASE_IMAGE': project.rootProject.hasProperty(["go-base-image"]) ? | ||
| project.rootProject["go-base-image"] : | ||
| "golang:1.17-buster" ]) | ||
| } | ||
|
|
||
| // Ensure that we build the required resources and copy and file dependencies from related projects | ||
| dockerPrepare.dependsOn copyDockerfileDependencies | ||
This file contains hidden or 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,19 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * License); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an AS IS BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| rootProject.name = 'apache-beam-playground-backend-python' |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,29 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| // (the "License"); you may not use this file except in compliance with | ||
| // the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package fs_tool | ||
|
|
||
| import ( | ||
| "github.com/google/uuid" | ||
| ) | ||
|
|
||
| const ( | ||
| pythonExecutableFileExtension = ".py" | ||
| ) | ||
|
|
||
| // newPythonLifeCycle creates LifeCycle with go SDK environment. | ||
| func newPythonLifeCycle(pipelineId uuid.UUID, workingDir string) *LifeCycle { | ||
| return newInterpretedLifeCycle(pipelineId, workingDir, pythonExecutableFileExtension) | ||
| } |
This file contains hidden or 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,79 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| // (the "License"); you may not use this file except in compliance with | ||
| // the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package fs_tool | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "github.com/google/uuid" | ||
| "reflect" | ||
| "testing" | ||
| ) | ||
|
|
||
| func Test_newPythonLifeCycle(t *testing.T) { | ||
| pipelineId := uuid.New() | ||
| workingDir := "workingDir" | ||
| baseFileFolder := fmt.Sprintf("%s/%s/%s", workingDir, baseFileFolder, pipelineId) | ||
|
|
||
| type args struct { | ||
| pipelineId uuid.UUID | ||
| workingDir string | ||
| } | ||
| tests := []struct { | ||
| name string | ||
| args args | ||
| want *LifeCycle | ||
| }{ | ||
| { | ||
| // Test case with calling newPythonLifeCycle method with correct pipelineId and workingDir. | ||
| // As a result, want to receive an expected python life cycle. | ||
| name: "newPythonLifeCycle", | ||
| args: args{ | ||
| pipelineId: pipelineId, | ||
| workingDir: workingDir, | ||
| }, | ||
| want: &LifeCycle{ | ||
| folderGlobs: []string{baseFileFolder}, | ||
| Folder: Folder{ | ||
| BaseFolder: baseFileFolder, | ||
| SourceFileFolder: baseFileFolder, | ||
| ExecutableFileFolder: baseFileFolder, | ||
| }, | ||
| Extension: Extension{ | ||
| SourceFileExtension: pythonExecutableFileExtension, | ||
| ExecutableFileExtension: pythonExecutableFileExtension, | ||
| }, | ||
| pipelineId: pipelineId, | ||
| }, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := newPythonLifeCycle(tt.args.pipelineId, tt.args.workingDir) | ||
| if !reflect.DeepEqual(got.folderGlobs, tt.want.folderGlobs) { | ||
| t.Errorf("newPythonLifeCycle() folderGlobs = %v, want %v", got.folderGlobs, tt.want.folderGlobs) | ||
| } | ||
| if !reflect.DeepEqual(got.Folder, tt.want.Folder) { | ||
| t.Errorf("newPythonLifeCycle() Folder = %v, want %v", got.Folder, tt.want.Folder) | ||
| } | ||
| if !reflect.DeepEqual(got.Extension, tt.want.Extension) { | ||
| t.Errorf("newPythonLifeCycle() Extension = %v, want %v", got.Extension, tt.want.Extension) | ||
| } | ||
| if !reflect.DeepEqual(got.pipelineId, tt.want.pipelineId) { | ||
| t.Errorf("newPythonLifeCycle() pipelineId = %v, want %v", got.pipelineId, tt.want.pipelineId) | ||
| } | ||
| }) | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
playground/backend/internal/preparators/python_preparators.go
This file contains hidden or 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,23 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| // (the "License"); you may not use this file except in compliance with | ||
| // the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package preparators | ||
|
|
||
| const () | ||
|
|
||
| // GetPythonPreparators returns preparation methods that should be applied to Python code | ||
| func GetPythonPreparators(filePath string) *[]Preparator { | ||
| return &[]Preparator{} | ||
| } |
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.
ah this is interesting - now that I think about this, we should mention in the README that to update runtime environments, we need to change these config files (we cna leave it for later)