From 4a60f802d0cc611b69967f5c5e29d24cdd123e3c Mon Sep 17 00:00:00 2001 From: Jeroen ter Heerdt Date: Fri, 1 Mar 2019 11:03:13 -0800 Subject: [PATCH] updating readmes for addpy and magic8ball samples. --- .../app-deploy/addpy/README.md | 2 +- .../app-deploy/magic8ball/README.md | 109 ++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 samples/features/sql-big-data-cluster/app-deploy/magic8ball/README.md diff --git a/samples/features/sql-big-data-cluster/app-deploy/addpy/README.md b/samples/features/sql-big-data-cluster/app-deploy/addpy/README.md index 25f11e1a..00ae4254 100644 --- a/samples/features/sql-big-data-cluster/app-deploy/addpy/README.md +++ b/samples/features/sql-big-data-cluster/app-deploy/addpy/README.md @@ -1,4 +1,4 @@ -# Running a Python script in SQL Server big data cluster +# Running a basic Python script in SQL Server big data cluster ### Contents diff --git a/samples/features/sql-big-data-cluster/app-deploy/magic8ball/README.md b/samples/features/sql-big-data-cluster/app-deploy/magic8ball/README.md new file mode 100644 index 00000000..3af97388 --- /dev/null +++ b/samples/features/sql-big-data-cluster/app-deploy/magic8ball/README.md @@ -0,0 +1,109 @@ +# Running a Magic 8-ball Python script in SQL Server big data cluster + +### Contents + +[About this sample](#about-this-sample)
+[Before you begin](#before-you-begin)
+[Run this sample](#run-this-sample)
+[Sample details](#sample-details)
+[Related links](#related-links)
+ + + +## About this sample + +This is a sample [Python](https://www.python.org/) app, which runs a [Magic 8-Ball](https://en.wikipedia.org/wiki/Magic_8-Ball). This sample creates an app that adds requires a question as input and returns an answer to the question. The code for this sample is in [magic8ball.py](magic8ball.py) The inputs and outputs are shown below. + +### Inputs +|Parameter|Description| +|-|-| +|`txt`|The input question on which you would like answered| + +### Outputs +|Parameter|Description| +|-|-| +|`result`|The answer of the Magic 8-ball| + + + + +## Before you begin + +To run this sample, you need the following prerequisites. + +**Software prerequisites:** + +1. SQL Server big data cluster CTP 2.3 or later. +2. `mssqlctl`. Refer to [installing mssqlctl](https://docs.microsoft.com/en-us/sql/big-data-cluster/deploy-install-mssqlctl?view=sqlallproducts-allversions) document on setting up the `mssqlctl` and connecting to a SQL Server 2019 big data cluster. + + + +## Run this sample + +1. Clone or download this sample on your computer. +2. Log in to the SQL Server big data cluster using the command below using the IP address of the `endpoint-service-proxy` in your cluster. If you are not familiar with `mssqltctl` you can refer to the [documentation](https://docs.microsoft.com/en-us/sql/big-data-cluster/big-data-cluster-create-apps?view=sqlallproducts-allversions) and then return to this sample. + + ```bash + mssqlctl login -e https://:30777 -u -p + ``` +3. Deploy the application by running the following command, specifying the folder where your `spec.yaml` and `magic8ball.py` files are located: + ```bash + mssqlctl app create --spec ./magic8ball + ``` +4. Check the deployment by running the following command: + ```bash + mssqlctl app list -n magic8ball -v [version] + ``` + Once the app is listed as `Ready` you can continue to the next step. +5. Test the app by running the following command: + ```bash + mssqlctl app run -n magic8ball -v [version] --input txt="Will it rain tomorrow?" + ``` + You should get output like the example below. The answer to your question are returned as `result`. + ```json + { + "changedFiles": [], + "consoleOutput": "", + "errorMessage": "", + "outputFiles": {}, + "outputParameters": { + "result": "You may rely on it" + }, + "success": true + } + ``` +6. You can clean up the sample by running the following commands: + ```bash + # delete app + mssqlctl app delete --name magic8ball --version [version] + ``` + + + +## Sample details + +Please refer to [magic8ball.py](magic8ball.py) for the code for this sample. + +### Spec file +Here is the spec file for this application. As you can see the sample uses the `Python` runtime and calls the `magic8ball` method in the `magic8ball.py` file, accepting a `str` input called `txt` (the question that you ask the Magic 8-ball) and returning a `str` output named `result`. + +```yaml +name: magic8ball +version: v2 +runtime: Python +src: ./magic8ball.py +entrypoint: magic8ball +replicas: 1 +poolsize: 1 +inputs: + txt: str +output: + result: str +``` + + + +## Related Links +For more information, see these articles: + +[How to deploy and app on SQL Server 2019 big data cluster (preview)](https://docs.microsoft.com/en-us/sql/big-data-cluster/big-data-cluster-create-apps?view=sqlallproducts-allversions) \ No newline at end of file