You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Playground] Resolve issue with SCIO examples failing on start due to a timeout (#24946)
* Initialize SBT cache during SCIO playground container build
Run sbt tool during container build to let it download Scala dependencies form Maven during build time instead of having to wait for downloading all dependencies during first run of examples in container
* Fix issue with reading of GRPC_TIMEOUT environment variables in CI/CD scripts
* Fix cleanup of execution environment for Scala examples
* Fix panic in preparers when an empty file is passed
* Use better name for SCIO project directory
* Run "sbt compile" during container build to fetch all Scala dependencies
* Disable forking JVM in SBT to significantly reduce memory usage
* Impose memory limits on local deployments of SCIO runner container to better imitate real deployments
* Fine-tune Java GC to improve performance and memory usage of SCIO examples
* Remove large blobs of text from common_test.go
* Add `sbt` to the list of development dependencies
* Clarify running of backend tests in Playground
* Clarify local running of backend
* Improve consistency in code blocks in backend Readme
* Fixing trailing whitespace
* Update playground/backend/README.md
Co-authored-by: Danny McCormick <dannymccormick@google.com>
* Update playground/backend/internal/utils/preparers_utils_test.go
Co-authored-by: Danny McCormick <dannymccormick@google.com>
---------
Co-authored-by: Danny McCormick <dannymccormick@google.com>
Copy file name to clipboardExpand all lines: playground/backend/README.md
+51-10Lines changed: 51 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,43 +27,84 @@ no setup.
27
27
28
28
## Getting Started
29
29
30
-
See [playground/README.md](../README.md) for details on requirements and setup.
30
+
See [playground/README.md](../README.md) for details on installing development dependencies.
31
31
32
32
This section describes what is needed to run the backend application.
33
33
34
34
- Go commands to run/test the backend locally
35
35
- Set up environment variables to run the backend locally
36
36
- Running the backend via Docker
37
37
38
-
###Go commands to run/test application locally
38
+
## Go commands to run/test application locally
39
39
40
+
### Prerequisite
41
+
42
+
> **Google Cloud Shell note:**`start_datastore_emulator.sh` script makes use of `nc` and `lsof` commands which are not installed on Google Cloud Shell machines. You can install them using `sudo apt install netcat lsof`.
43
+
44
+
> **Google Cloud Shell note:** run `unset GOOGLE_CLOUD_PROJECT` before running tests so they would use locally running datastore emulator.
45
+
46
+
Start datastore emulator
47
+
```shell
48
+
bash start_datastore_emulator.sh
49
+
```
50
+
51
+
After you have finished running tests
52
+
```shell
53
+
bash stop_datastore_emulator.sh
54
+
```
55
+
56
+
### Run/build
40
57
Go to the backend directory:
41
58
42
59
```shell
43
-
$ cd backend
60
+
cd backend
44
61
```
45
62
46
-
The following command is used to build and serve the backend locally:
63
+
To run backend server on development machine without using docker you'll need first to prepare a working directory anywhere outside of Beam source tree:
64
+
```shell
65
+
mkdir ~/path/to/workdir
66
+
```
67
+
and then copy `datasets/` and `configs/` and `logging.properties` from [`playground/backend/`](/playground/backend/) directory:
In case if you want to start backend for Go SDK you additionally will also need to create a prepared mod dir and export an additional environment variable:
The following command will build and serve the backend locally:
79
+
80
+
```shell
81
+
SERVER_PORT=<port> \
82
+
BEAM_SDK=<beam_sdk_type> \
83
+
APP_WORK_DIR=<path_to_workdir> \
84
+
DATASTORE_EMULATOR_HOST=127.0.0.1:8888 \
85
+
DATASTORE_PROJECT_ID=test \
86
+
SDK_CONFIG=../sdks-emulator.yaml \
87
+
go run ./cmd/server
88
+
```
89
+
90
+
where `<port>` should be the value of port on which you want to have the backend server available; `<beam_sdk_type>` is a value of desired Beam SDK, possible values are `SDK_UNSPECIFIED`, `SDK_JAVA`, `SDK_PYTHON`, `SDK_GO`, `SDK_SCIO`; `<path_to_workdir>` should be set to path to your work dir, e.g. `~/path/to/workdir`.
91
+
52
92
Run the following command to generate a release build file:
53
93
54
94
```shell
55
-
$ go build ./cmd/server/server.go
95
+
go build ./cmd/server/server.go
56
96
```
57
97
98
+
### Test
58
99
Playground tests may be run using this command:
59
100
60
101
```shell
61
-
$ go test ... -v
102
+
go test./... -v
62
103
```
63
104
64
105
The full list of commands can be found [here](https://pkg.go.dev/cmd/go).
65
106
66
-
###Set up environment variables to run the backend locally
107
+
## Set up environment variables to run the backend locally
67
108
68
109
These environment variables should be set to run the backend locally:
69
110
@@ -96,7 +137,7 @@ default value and there is no need to set them up to launch locally:
96
137
-`PROPERTY_PATH` - is the application properties path (default value = `.`)
97
138
-`CACHE_REQUEST_TIMEOUT` - is the timeout to request data from cache (default value = `5 sec`)
98
139
99
-
###Application properties
140
+
## Application properties
100
141
101
142
These properties are stored in `backend/properties.yaml` file:
102
143
@@ -106,7 +147,7 @@ These properties are stored in `backend/properties.yaml` file:
106
147
-`removing_unused_snippets_cron` - is the cron expression for the scheduled task to remove unused snippets.
107
148
-`removing_unused_snippets_days` - is the number of days after which a snippet becomes unused.
108
149
109
-
###Running the server app via Docker
150
+
## Running the server app via Docker
110
151
111
152
To run the server using Docker images there are `Docker` files in the `containers` folder for Java, Python and Go
112
153
languages. Each of them processes the corresponding SDK, so the backend with Go SDK will work with Go
0 commit comments