IBM Watson Data & AI - Structured Ideas

Welcome to the idea forum for IBM Watson Data & AI — our team welcomes any feedback, requests, and suggestions you have for improving our products! 

This forum allows us to connect your product improvement ideas with IBM product and engineering teams. 

Allow services to be bound to a project like bluemix applications where the credentials are passed in via VCAP_SERVICES

Couldn’t we follow the same pattern as Bluemix apps where services would be bound to the app (DSX project) and use the VCAP_SERVICES environment variable?

vcap_services = os.getenv("VCAP_SERVICES")
vcap = json.loads(vcap_services)

# Cloudant details

cloudant_credentials = vcap['cloudantNoSQLDB'][0]['credentials']

CL_HOST = cloudant_credentials['host']
CL_USER = cloudant_credentials['username']
CL_PASS = cloudant_credentials['password']
CL_URL = cloudant_credentials['url']

  • chris snow
  • Dec 14 2018
  • Under Consideration
Role Summary
  • Attach files
  • chris snow commented
    14 Dec 17:58

    It may make most sense to apply services to the spark service so that we can still access the vcap_services variable from a spark submit job (I.e. Not using Dsx)

  • chris snow commented
    14 Dec 17:58

    Here's an example java (spring) config for connecting to a data source via vcap services:

    public class Configuration {
    @Configuration
    @Profile("cloud")
    static class CloudConfiguration {

    @Bean
    public DataSource dataSource() {
    CloudFactory cloudFactory = new CloudFactory();
    Cloud cloud = cloudFactory.getCloud();
    String serviceID = cloud.getServiceID();
    return cloud.getServiceConnector(serviceID, DataSource.class, null);
    }
    }
    ...

    https://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html#cloud-profiles

  • Dejan Glozic commented
    14 Dec 17:58

    This already exists in a rudimentary form. Projects already have certain services (Spark, Machine Learning) that are bound to projects so that all project members can use them. Notebooks use this today, and so does the upcoming Machine Learning model builder. We are going to push more in this direction in the future.

  • chris snow commented
    14 Dec 17:58

    @dejan is there an interim solution we could provide where a field is provided in project settings for pasting a VCAP_SERVICES json string and then setting the VCAP_SERVICES environment variable based on that? We could maybe put this in a section of project settings called advanced.

  • Daniel Debrunner commented
    14 Dec 17:58

    Exactly what I need!

  • chris snow commented
    14 Dec 17:58

    The benefits of this approach:

    - same code can be used in notebooks and bluemix apps
    - variables aren't hardcoded into notebooks

  • Philippe GREGOIRE commented
    14 Dec 17:58

    Getting access to `project-lib` tokens would allow to then get access to other resources such as COS objects and Connection artifacts too.
    Currently one has to explicitly paste that in the notebook code even though it would be a %hidden_cell

  • Guest commented
    14 Dec 17:58
  • Sanjay Joshi commented
    14 Dec 17:58

    Love embracement of loose coupling !