Combining library sets

You can install Python packages via pip or conda, and download a file as part of the library set by combining these options when you create the library set.

You can use the combination option as shown in the following example:

{
  "application_details": {
    "application": "/opt/ibm/customization-scripts/customize_instance_app.py",
    "arguments": ["{\"library_set\":{\"action\":\"add\",\"name\":\"multi_library\",\"libraries\":{\"pip\":{\"python\":{\"packages\":[\"numpy\"]}}},\"script\":{\"source\":\"py_files\",\"params\":[\"script_params\"]}}}"],
    "py-files": "cos://<bucket>.dev-cos/jar/customization_script.py",
    "conf": {
      "spark.hadoop.fs.cos.dev-cos.endpoint": "https://s3.direct.us-south.cloud-object-storage.appdomain.cloud",
      "spark.hadoop.fs.cos.dev-cos.access.key": "<cos_access_key>",
      "spark.hadoop.fs.cos.dev-cos.secret.key": "<cos_secret_key>"
    }
  }
}

To increase readability, the unescaped JSON for the arguments would look as follows:

{
  "library_set": {
    "action": "add",
    "name": "multi_library",
    "libraries": {
      "pip": {
        "python": {
          "packages": ["numpy"]
        }
      }
    },
    "script": {
      "source": "py_files",
      "params": ["script_params"]
    }
  }
}