vania-janet/multiturn-rag-retrieval-data huggingface dataset:
This code generates a joint plot in [seaborn](https://seaborn.pydata.org/) that uses random data. You can then create a web action with Cloud Functions to return the plot to a Cloud Functions endpoint.

 import modules
import base64
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

 optional: set seaborn style
sns.set(style="dark")
def main(args):
generate a jointplot from random data.
x, y = np.random.randn(2, 300)
g = (sns.jointplot(x,y, kind="hex", color="9b59b6")
.set_axis_labels("x", "y"))
 save the plot as a .png so that it can be base64 encoded/decoded.
plt.savefig('output.png')
 open, read, and encode the image.
image = base64.b64encode(open("output.png", "rb").read())
 decode the image into a string.
data = image.decode('utf-8')
 return the string as a JSON web request.
return {
'body': data,
'statusCode': 200,
'isBase64Encoded': 'true',
'headers': {'Content-Type': 'image/png'}
}
Show more
10. Create a web action called seaborn by using the custom Docker image that you created that contains the required Python dependencies to run a joint plot.

ibmcloud fn action create seaborn --docker <dockerhub_username>/<repo_name>:<tag_name> seaborn.py --web true

Example output

ok: created action seaborn
11. Invoke the action to test it.
SYSDIG_TOKEN = sys.argv[2]

DASHBOARD_NAME = 'My New Dashboard from Python'
PANEL_NAME = 'CPU Over Time'

sdclient = SdMonitorClient(token=SYSDIG_TOKEN,sdc_url=URL)

 Create an empty dashboard
ok, res = sdclient.create_dashboard(DASHBOARD_NAME)

 Check the result
dashboard_name = None
if ok:
print('Dashboard %d created successfully' % res['dashboard'])
dashboard_name = res['dashboard']
else:
print(res)
sys.exit(1)

 Add a time series panel
panel_type = 'timeSeries'
metrics = [
{'id': 'proc.name'},
{'id': 'cpu.used.percent', 'aggregations': {'time': 'avg', 'group': 'avg'}}
]
ok, res = sdclient.add_dashboard_panel(
dashboard_name, PANEL_NAME, panel_type, metrics)

 Check the result
if ok:
print('Panel added successfully')
dashboard_name = res['dashboard']
else:
print(res)
sys.exit(1)
Show more





 Copy a dashboard 

You can use Python to copy dashboards.



 Copy a custom dashboard in the default team 

The following code shows the structure of a Python script to copy a custom dashboard to the default team.

!/usr/bin/env python3

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import IbmAuthHelper, SdMonitorClient

 Parse arguments.
def usage():
Get a copy of the PDF so that you can upload it to your project. You can download the file from the [US Securities and Exchange Commission](https://www.sec.gov/tm/reports-and-publications/special-studies/algo_trading_report_2020) website.
2. From the Select data source page, click Upload data, and then click Next.

Zoom

![Shows the data source options.](https://cloud.ibm.com/docs-content/v1/content/f16b1f78a92498247223b337bd9303c2758b9ba8/discovery-data/images/tut-sdu-upload-data.png)

Figure 2. Data source options
3. In the Collection name field, add Algorithmic Trading PDF, and then click Next.

Zoom

![Shows the collection name field](https://cloud.ibm.com/docs-content/v1/content/f16b1f78a92498247223b337bd9303c2758b9ba8/discovery-data/images/tut-sdu-add-pdf.png)

Figure 3. Uploaded data collection name field
4. Drag the file that you downloaded to the page and drop it into the tile with the Drag and drop files here or upload link.

Zoom

![Shows the tile where you drag the file that you want to upload.](https://cloud.ibm.com/docs-content/v1/content/f16b1f78a92498247223b337bd9303c2758b9ba8/discovery-data/images/tut-sdu-drag-file.png)

Figure 4. File upload dialog
5. Click Finish.

You add only one file. In a real scenario, you might upload multiple files with information about the same topic.
* On systems such as Ubuntu and Debian that use deb packages, use a command such as the following: dpkg -i /full/path/to/deb/package/deb-file-name
* The Crawler scripts are installed into {installation directory}/bin; for example, /opt/ibm/crawler/bin. Ensure that {installation_directory}/bin is in your PATH environment variable for the Crawler commands to work correctly.



Crawler scripts are also installed to /usr/local/bin, so this can be added to your PATH environment variable as well.







 Create your working directory 

Copy the contents of the {installation_directory}/share/examples/config directory to a working directory on your system, for example /home/config.

Do not modify the provided configuration example files directly. Copy and then edit them. If you edit the example files in-place, your configuration might be overwritten when upgrading the Data Crawler, or it might be removed when uninstalling it.

References in this guide to files in the config directory, such as config/crawler.conf, refer to that file in your working directory, not in the installed {installation_directory}/share/examples/config directory.





 Configure crawl options 

To set up the Data Crawler to crawl your repository, you must specify which local system files you want to crawl, and which Discovery instance to send the collection of crawled files to after the crawl finishes.



1. filesystem-seed.conf - Open the seeds/filesystem-seed.con file in a text editor. Modify the value attribute directly under the name-"url" attribute to the file path that you want to crawl. For example: value-"sdk-fs:///TMP/MY_TEST_DATA/"

The URLs must start with sdk-fs://. So to crawl, for example, /home/watson/mydocs, the value of this URL is sdk-fs:///home/watson/mydocs. The third / in the URL is necessary.

Save and close the file.
Run the Python script by using python3 to update the variables in the Schematics workspace in the IBM Cloud.

The following parameters might not be required in config.json as the Schematics update variables API uses the workspace ID w_id to update the variables against that workspace.

{
  "name": "Schematic Dev Workspace",
  "type": [
    "terraform_v0.14"
  ],
  "location": "us-south",
  "description": "Schematic Dev Workspace",
  "tags": [],
  "template_repo": {
    "url": "<GitHub repo URL>",
    "githubtoken": "<github-token>"
  }



 Example Python request for schematics_variables_update.py file 

The following Python example request is for the example file, schematics_variables_update.py.

import logging, os, json

logging.basicConfig()
logging.root.setLevel(logging.NOTSET)
logging.basicConfig(level=logging.NOTSET)

from schematics_env_class import HPCCEnvironmentValues

logging.info("Schematic Variable Update Started")

if __name__ == '__main__':

    json_files = os.path.join(os.path.abspath("."), "config.json")

    with open(json_files, "r") as file:
        config_data = json.load(file)

    api_key = config_data["template_data"]["variablestore"]["value"]

    schematic_obj = HPCCEnvironmentValues(api_key)

    workspace_response = schematic_obj.schematics_service.get_workspace(w_id="<workspace id>").get_result()
To access the advanced user options, go to the More Tools tab.



* Specify an existing Cloud Object Storage instance to store transient build artifacts:



* Specify the name of the bucket in your Object Storage instance where you want to store the transient build artifacts. To upload objects to the bucket, it must reside in the same region where the toolchain is created.
* Select the API Key that has read and write access to the bucket that you specified.



Zoom

![Cloud Object Storage Integration Details](https://cloud.ibm.com/docs-content/v1/content/562806c0b18119f4d21cb66f5ae6d051634b4a16/ContinuousDelivery/images/custom_cos.png)

Figure 8. Cloud Object Storage integration details
* To use an Artifactory account to store transient build artifacts, specify details for your Artifactory instance:



* Artifactory Server URL: HTTPS URL of the Artifactory Server
* Type: Choose from npm, maven, or docker
* Artifactory UserID: User ID to log in to the Artifactory Server, in the xxx.xxx@xxx.com format
* Artifactory APIKey: APIKey generated by the User (Existing or New)
* Release URL: Release URL for the Artifactory repo where artifacts are stored





Some fields in the Artifactory are mandatory only when you use the Artifactory configuration.

Zoom

![Artifactory Integration Details](https://cloud.ibm.com/docs-content/v1/content/562806c0b18119f4d21cb66f5ae6d051634b4a16/ContinuousDelivery/images/artifactory_details.png)

Figure 9. Artifactory integration details

Click Create to create the toolchain. This process might take several minutes to complete.





 Step 4: Optional. Roll back to the previous version of the deployed application 

You might want to roll back the deployed code because of test results, code quality issues, and other issues.
* A [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with repo access.







 Step 1: Create a webhook with Cloud Functions 

Let's start by creating a [Cloud Functions](https://cloud.ibm.com/docs/openwhisk) action. A Cloud Functions action is a piece of code that can be run in response to a trigger, such as an incoming notification from the Event Notifications service. Your Cloud Functions action can contain code that takes an incoming payload from Event Notifications, which originated as an event in Secrets Manager, and uses it to create a GitHub issue.



 Create a Cloud Functions action 

To create a Cloud Functions action, you can use the Functions UI.



1. In the IBM Cloud console, click the Menu icon ![Menu icon](https://cloud.ibm.com/docs-content/v1/content/991f60ddbe3ab0a9aa69481a07a0a73b359fa329/icons/icon_hamburger.svg)> Functions.
2. In the navigation, click Actions > Create.
3. Give the action a name. For example, sm-notifications-github.
4. Choose the default package.
5. Select a Node.js runtime.
6. Click Create.







 Obtain your new webhook URL 

In part 1 of this tutorial series, you used [Webhook.site](https://webhook.site) to test your notifications workflow for the first time. Now that you've set up a Cloud Functions action, you can also use it to receive any incoming notifications.



1. From the Cloud Functions action menu, click Endpoints.
2. Select Enable as Web Action.
3. Select Raw HTTP handling.
4. Click Save.
5. Copy the URL.
Future<AsperaTransaction> asperaTransactionFuture = asperaTransferMgr.download(bucketName, itemName, outputPath);
AsperaTransaction asperaTransaction = asperaTransactionFuture.get();

Show more

Key Values



* <bucket-name> - name of the bucket in your Object Storage service instance that has Aspera enabled.
* <absolute-path-to-file> - directory and file name to save from Object Storage.
* <item-name> - name of the object in the bucket.







 Directory Upload 

String bucketName = "<bucket-name>";
String directoryPath = "<absolute-path-to-directory-for-new-file>";
String directoryPrefix = "<virtual-directory-prefix>";
boolean includeSubDirectories = true;

// Load Directory
File inputDirectory = new File(directoryPath);

// Create AsperaTransferManager for FASP upload
AsperaTransferManager asperaTransferMgr = new AsperaTransferManagerBuilder(COS_API_KEY_ID, s3Client)
.withTokenManager(tokenManager)
.withAsperaConfig(asperaConfig)
.build();

// Upload test directory
Future<AsperaTransaction> asperaTransactionFuture = asperaTransferMgr.uploadDirectory(bucketName, directoryPrefix, inputDirectory, includeSubDirectories);
AsperaTransaction asperaTransaction = asperaTransactionFuture.get();
Show more

Key Values



* <bucket-name> - name of the bucket in your Object Storage service instance that has Aspera enabled.
* <absolute-path-to-directory> - directory of the files to be uploaded to Object Storage.
* SPDYSTREAM/DOCS [docker/spdystream](https://cloud.ibm.com/spdystream-449fdfce4d962303d702fec724ef0ad181c92528/README.md), FIXTURES [go-openapi/spec] (Not Required)
* DOCS [containerd/containerd (Not Required)](http://creativecommons.org/licenses/by/4.0/), EXPANDER_TEST.GO [go-openapi/spec (Not Required)](https://proxy.golang.org/github.com/go-openapi/spec/@v/v0.19.3.zip)







 Creative Commons Attribution Share Alike 1.0 Generic 

The Program includes some or all of the following works licensed under the Creative Commons. The URL to the license is [https://creativecommons.org/licenses/by-sa/1.0/legalcode](https://creativecommons.org/licenses/by-sa/1.0/legalcode).

TXT_RU [golang/text](https://github.com/golang/text/archive/v0.3.0.zip)





 Creative Commons Attribution Share Alike 2.0 Generic 

The Program includes some or all of the following works licensed under the Creative Commons. The URL to the license is [https://creativecommons.org/licenses/by-sa/2.0/legalcode](https://creativecommons.org/licenses/by-sa/2.0/legalcode)



* MASTER SHAKE PHOTO BY SOL GRUNDY (MASTER_SHAKE.JPG) [rest-client (Ruby Gem)](https://rubygems.org/gems/rest-client-1.8.0.gem)
* TXT_KR [golang/text](https://github.com/golang/text/archive/v0.3.0.zip)







 Creative Commons Attribution Share Alike 2.5 Generic
If they are in a private repository, create [private code repository access](https://cloud.ibm.com/docs/codeengine?topic=codeengine-code-repositories) and then provide that value with the --build-git-repo-secret option. If your files are located in a directory other than main, provide the path to the directory with the --build-context-dir option.

ibmcloud ce fn create -n pyjokes -runtime python-3.11 --build-source GITHUB_DIR
4. Invoke your Function by pasting the provided URL into a web browser. Your browser displays a random joke!



For more information about the fn create command and its options, see [Create a Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-function-create).







 Next steps 

Looking for more code examples? Check out the [Samples for IBM Cloud Code Engine GitHub repo](https://github.com/IBM/CodeEngine).
* Complete the following steps to enable website to initialize the SDK.

var enPush = new ENPush()

function callback(response) {
alert(response.response)
}

var initParams = {
"instanceGUID": "<instance_guid>",
"apikey": "<instance_apikey>",
"region": "<region>",
"deviceId": "<YOUR_DEVICE_ID>",
"chromeDestinationId": "<chrome_destination_id>",
"chromeApplicationServerKey": "<Chrome_VapId_public_key>"
}

enPush.initialize(initParams, callback)
Show more



* region: Region of the Event Notifications instance. For example, us-south,eu-gb, au-syd or eu-de.
* deviceId: Optional deviceId for device registration.



* To register for notifications, use the register() or registerWithUserId() API to register the device with Event Notifications service. Choose either of the following options:



* Register without UserId:

enPush.register(function(response) {
alert(response.response)
})
* Register with userId. For userId based notification, the register method accepts one more parameter - userId.

bmsPush.registerWithUserId("UserId",function(response) {
alert(response.response)
})

UserId is the user identifier value with which you want to register devices in the push service instance.



* The subscribe API subscribes the device for a tag. After the device is subscribed to a particular tag, the device can receive notifications that are sent for that tag. Add the following code snippet to your web application to subscribe to a list of tags.

enPush.subscribe(tagName, function(response) {
alert(response.response)
})
* When the setup is complete, run your application and register for push notifications.
Documentation 



 Interface documentation 

The SDK MUST have accompanying documentation that clearly describes all public methods and classes of the SDK. This includes full documentation for method parameters and responses and all member variables of classes.

The interface documentation SHOULD use terminology that is appropriate for the programming language (e.g. Java objects should not be described as "JSON", and methods for service invocations should not be described as a "GET /v3/path/to/the/service").





 Delivery format 

SDK interface documentation SHOULD be integrated into the [IBM Cloud API Reference](https://cloud.ibm.com/apidocs) for the service, where the SDK for each language appears in a separate tab.

SDK interface documentation SHOULD also be delivered in a format and location that experienced developers for a particular language / platform will find familiar:



* Javadoc for a Java SDK
* [TypeDoc](https://typedoc.org/api/index.html) for a Node SDK
* [Sphinx](http://www.sphinx-doc.org/en/master/) for a Python SDK
* [Package](https://pkg.go.dev) for a Go SDK
* Jazzy for a Swift SDK







 Tutorials and user guides 

Tutorials and user guides for the service SHOULD provide prominent references to the SDK. This should include how the SDK can be accessed through the package management systems appropriate for each language and how this can be automated in a DevOps pipeline flow for an application using the SDK.





 Migration guides 

Your SDK SHOULD provide a migration guide to help users upgrade to the latest version of your SDK.





 Examples 

The SDK MUST include or have accompanying examples that illustrate common usage flows involving multiple service APIs.

All IBM-developed coding examples and sample applications for the service SHOULD use the SDK.





 Contributor documentation 

The SDK MUST include documentation for developers that would like to contribute to the SDK either by opening issues or submitting pull requests.

In particular:



 Issue template and pull request template 

Provide issue and pull request templates to guide contributors on what information should be provided and what processes to follow when making contributions to the SDK.





 CONTRIBUTING.md
w_id='<workspace-id>',
    activity_id='<activity-ID>'
).get_result()

print(json.dumps(workspace_activity, indent=2))

logging.info("Completed Retrieving the Schematic logs")
Show more





 Example Python response 

The Python response is a generic example. Versioning and deployment values are subject to change due to frequent code updates.

INFO:root:Started Retrieving the Schematic logs
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): iam.cloud.ibm.com:443
DEBUG:urllib3.connectionpool:https://iam.cloud.ibm.com:443 "POST /identity/token HTTP/1.1" 200 992
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): us.schematics.cloud.ibm.com:443
DEBUG:urllib3.connectionpool:https://us.schematics.cloud.ibm.com:443 "GET /v1/workspaces/us-east.workspace.sunil-myworkspace-may12.2e0a560f/actions/6242ef71d4003bdae4a7ed7a3cbb0887 HTTP/1.1" 200 None
{
"action_id": "a11223334b11224345",
"name": "PLAN",
"status": "COMPLETED",
"message": [],
"performed_by": "user@us.ibm.com",
"performed_at": "2019-08-21T14:07:25.814722573Z",
"templates": [
{
"template_id": "a1234b-2124",
"template_type": "terraform_v0.12",
Project ID: 01234567-abcd-abcd-abcd-abcdabcd1111
Age: 20h
Created: 2022-11-28T13:16:49-06:00
URL: https://my-github-app.abcdabcdabc.us-south.codeengine.appdomain.cloud
Cluster Local URL: http://my-github-app.abcdabcdabc.svc.cluster.local
Console URL: https://cloud.ibm.com/codeengine/project/us-south/abcdefgh-abcd-abcd-abcd-1a2b3c4d5e6f/application/my-github-app/configuration
Status Summary: Application deployed successfully
...





 Step 2: Create a webhook 

Create a GitHub webhook to subscribe your application to GitHub events. You can subscribe to one or more webhook events. When an event that you subscribe to occurs, GitHub sends a payload to your application. For more information, see [Webhook events and payloads](https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads).

To create a GitHub webhook, follow these steps.



1. Go to your GitHub repository and select Settings.
2. Select Webhooks -> Add webhook. Note that your GitHub repository might use Hooks instead of Webhooks.
3. Enter your application URL as your Payload URL.
4. Select the Content type that your application requires. If you are using the sample github app, then select application/json as your content type.
5. Optional. Add a secret to your webhook.
ibmcloud iam api-key-create myapikey -d "API key for SBS tutorial"

The output displays the created API key. Make a note of the API Key value, you need it later to provide the API Key when you set up the Secure Build Server. The following snippet shows example output:

Creating API key myapikey under <your account id> as <your user id>...
OK
API key myapikey was created

Please preserve the API key! It cannot be retrieved after it is created.

ID ApiKey-...
Name myapikey
Description API key for SBS tutorial
Created At 2021-...
API Key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Locked false





 3. Run the following commands to install the container registry CLI plug-in and to create a new namespace secureimages in your container registry. 

ibmcloud plugin install container-registry
ibmcloud cr region-set us-south
ibmcloud cr namespace-add secureimages







 Step 2: Step 2: Set up the Secure Build Server 

Complete the steps in this procedure to set up the Secure Build Server.



 1. Install the IBM Cloud CLI HPVS plug-in by running the following command: 

ibmcloud plugin install hpvs

The Secure Build Server is written in Python and is tested with Python 3.6.9. To set up the Secure Build Server, you need to install python3, pip3, and the Secure Build Server on your workstation.





 2. Install python3 and pip3, by running the following commands: 

sudo apt-get update
sudo apt-get install python3 python3-pip
python3 -m pip install -U pip

Note: This tutorial shows the commands for Ubuntu. On other platforms, use the equivalent commands to install or update python3 and pip3.





 3. Use the following commands to install the Secure Build Server CLI on your workstation:
* [IBM Cloud integrations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-supported-integrationssupported-cloud-integrations)
* [Third-party integrations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-supported-integrationssupported-third-integrations)



[Running jobs with Lithops framework](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopslithops)



* [Running your first flow by using the Lithops framework](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopsfirst-lithops)



* [Installing Lithops](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopsinstall-lithops)
* [Setting up a storage backend for Lithops](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopsstorage-lithops)
* [Deploy your first Code Engine job by using Lithops](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopsrunning-first)
* [Next steps for Lithops](https://cloud.ibm.com/docs/codeengine?topic=codeengine-lithopsnextsteps-lithops)





[Validating your application code and latency with Iter8](https://cloud.ibm.com/docs/codeengine?topic=codeengine-slovalidationtutslovalidationtut)



* [Finding the URL of your Code Engine application](https://cloud.ibm.com/docs/codeengine?topic=codeengine-slovalidationtutgeturl-slovalidationtut)