Creating My First Data Access Extension For Lumira
After my initial posts on Predictive Custom R Scripts, i was advocating the idea that we need more extensibility on our new solutions, like a data connector sdk, enabling customers and partners to create new connectors.
Somebody must have heard me, Lumira Data Access Extensions were ready when we came to version 1.17 and anounced with a MongoDB connector here
From that moment, asking for this functionality i feel obliged to come up with an extension 🙂 I asked for it, now i need to use it right 🙂
1) The Idea,
I believe the hard to reach data sources would be “Cloud” ones, because they will all have a specific api that you need to talk to. To demonstrate this i decided to go with a Google Spreadsheets extension, so i can utilize my cloud spreadsheet data, and that data can be updated by other apps too.
2) The problem, and the solution
Ok, now the problem is how do i create an extension? Data Access Extensions Developer Guide explains it all! But what if you dont have any idea how to code, and how to create an executable? There Python language comes handy! You can very easily learn it, create your programs and pack them into executables. I can understand why it is so popular!
3) Lets create a Google Spreadsheet
1) Go to https://drive.google.com/ and create your Spreadsheet as illustrated :
2) Paste some data into your spreadsheet (first row needs to be column titles). I’m using the famous Titanic Dataset here.
3) At the next step we need to make our spreadsheet accesible without a login (so we don’t have to deal with authentication in the extension). I’ve chosen “Anyone with the link” can access it.
4) In addition to that, we need to “Publish” our spreadsheet to web, (from File -> Publish to the web) as illustrated in the following screenshots,
5) Now that our spreadsheet is ready, we can move on, but one final thing, our spreadsheet has a “key” that will help us reach it later. You can find it in the middle of spreadsheet url. Copy it down to somewhere handy :
4) Getting our Lumira ready for the extensions :
There are a few things you need to do to active Data Source Extensions in Lumira :
1) In C:\Program Files\SAP Lumira\Desktop, open SAPLumira.ini file.
2) Add the following entries to the SAPLumira.ini file, and save the file.
-Dhilo.externalds.folder=C:\Program Files\SAP Lumira\Desktop\daextensions
3) Create the folder “C:\Program Files\SAP Lumira\Desktop\daextensions”
We are ready to go!
5) The code :
Disclaimer : This is my first time trying Python and i’m in no means a programmer. So sorry for the disturbance and the sloppy coding 🙂 Also this extension is not supported by SAP! Do not use for anything serious!
I think the developer guide and the implementation method is pretty straightforward and i advise anyone intrested to have a look at the guide.
Lumira expects you to implement “Preview”, “Edit” and “Refresh” workflows, and send parameters and data in a specific format. The good thing is it stores your parameters safely so you dont have to ask for the url, key etc. again when user wants to refresh. You will be “reminded” by Lumira.
Let’s find out our parameters and in which workflow we are currently in :
Then all we need to do is to implement required dialogs and data access :
I can share the full Python code if someone’s intrested.
6) Let’s try our extension
After copying our result “.exe” file into the “C:\Program Files\SAP Lumira\Desktop\daextensions” directory, Lumira will have a new option in the Source pane. Select it and click “Next”, you will see our first extension waiting to be used :
When selected, you will see a popup window asking you for your spreadsheet key, paste your key and click ok.
Voila!!! We have our data preview! Click Create to acquire your data from Google Docs :
You can click “Ctrl – R” keyboard shortcut or use “Data –> Refresh” menu anytime to refresh your data from the source Google Spreadsheet.
7) Results, Executable And Next Steps :
I think i have reached a re-usable extension in the simplest manner.
To use it with your own Lumira, just copy it to the extensions directory, default is :
Again, this is just a personal project and is not supported by SAP
Disclaimer : This blog post and included extension is a personal project and is not supported by SAP. And not supported by me either! If you want to know what the code is doing, you can check the source codes that are also found in the github repository.
If i find some time, i’d enhance this extension to utilize authentication so you won’t have to make your spreadsheet public. And in dialogs i could provide your existing worksheets so you can chose one without the need for a key.
Another enhancement point would be to support proxies, meaning you can’t use it behind a proxy right now.
Coming up next… A Twitter extractor for Lumira !!!