How do you use/reference libraries in IBM Bluemix OpenWhisk? - ibm-cloud

As of today, in the IBM Bluemix docs for the IBM Bluemix OpenWhisk service I could not find any clues as to how to use libraries.
How am I missing the obvious that all apps invariably require a library and therefore why isn't that at least mentioned in the OpenWhisk docs?
If libraries are called something else or the concept doesn't apply in the usual way (such as maybe Libraries need to be converted into "OpenWhisk Packages"?), the OpenWhisk docs should SAY SOMETHING about the word/term/concept "libraries".

You can use webpack to bundle all your dependencies and create the final .js file you'll use as your OpenWhisk action.
See this example:
These are all the actions before webpack build: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/tree/dev/actions
Invoking webpack: https://github.com/IBM-Bluemix/logistics-wizard-recommendation/blob/dev/package.json webpack --config webpack.config.js
Here is another more simpler example: https://github.com/IBM-Bluemix/openwhisk-webpack

To cover another language for anyone who finds this question…
For Swift, OpenWhisk comes with the Kitura-net, SwiftyJSON & swift-watson-sdk packages (Swift term for libraries) built in.
If you want to include any other packages then you have to either build your own Docker container for your action or concatenate all the Swift source files that are in the packages together with your action file to create a single .swift file for upload with wsk action update. I've used cat to do this:
cat lib/Redis/Redis*.swift actions/_common.swift actions/counts.swift > build/counts.swift
which creates a single build/counts.swift containing Kitura-Redis, some common code and my counts action.

Related

How to create python libraries and how to import it in palantir foundry

In order to generalize the python functions, I wanted to add functions to python libraries so that I can use these function across the multiple repositories. Anyone please answer the below questions.
1) How to create our own python libraries
2) how to import those libraries across multiple repositories
How to create python libraries in Palantir Foundry?
To create a new library, you can do so by creating a new repository. When prompted to initialise the repository, you should have an option that reads:
Python Library
Template for publishing a Python library package. Consuming new libraries has changed,
please read README in library repository.
The readme will contain instructions on how to publish a library. It is recommended you understand how conda publishing channels work for this.
A note, avoid using _ in the library name, since it can cause problems. - is safe to use though.
How to import a library in code authoring?
Once your library is publishing, you can add it to your conda recipe of the repository you want to consume the library in. You can find this in: transforms-python/conda_recipe/meta.yaml
Afterwards just add it to the list of under
requirements:
run:
- python
- pandas
- your-library-name
In addition to fmsf's answer, in the second step you might have to add the following content to the build.gradle of your transforms-python directory:
transformsPython {
sharedChannels "libs"
}

OpenWhisk- How to upload package actions?

I am new to OpenWhisk. I am currently using AWS Lambda(node.js) to generate custom tokens. Lambda has an option to upload the Zip file as a package. Does OpenWhisk have a similar option? I couldn't find any doc related to such an option.
OpenWhisk now (24th October 2016) supports uploading a zip file with your Node.js source files and NPM modules to run as an Action.
This documentation page has details on how to use this feature.
$ wsk action create packageAction --kind nodejs:6 action.zip

How to "pack" an Ember CLI component?

I'm using ember-cli and I made a custom component using ember-cli syntax & naming conventions. This is a highly reusable component and I'd like to know what is the better way to put it all into a "package" so it's easy to integrate into other projects.
My component use a .js file for the Ember.Component subclass along with a .hbs file for the template and yet another couple of .js files for the necessary Ember.View subclasses. Right now, every file is in its respective folder along with the files for the rest of my project.
How can I isolate the files related to the component and package them for reuse? In Ruby on Rails I use gems for this matter, and in jQuery I used to write plugins by extending $.fn in a single file.
Take advantage of Ember CLI addon system. It's been designed for cases like this one. The process should be easy if you are familiar with Ember CLI already. As Ember CLI addon system's been reworked in the recent past and it's API was changing it's possible that older articles or guides on this topic became out of sync.
The most comprehensive and kept in sync guide on this topic is kristianmandrup's gist Converting libraries to Ember CLI addons.
There is also an Addons tutorials section on the official Ember CLI site.

Ember cli - use sass addon in less project

I use broccoli-less in my ember cli project and would like to use an addon (ember-cli-materialize), which uses broccoli-sass.
After installing the addon, i get: File to read not found or unreadable ../app.scss, because i also have an app.less file in my styles dir.
As i understand, this commit Allow multiple preprocessors per type should make it possible, although i might be missing something. Has anyone managed to use ember-cli with multiple preprocessors, and what changes is needed?
Ember-cli version: 1.13.1
Ember version: 1.12.0
Thanks
I know your circumstance is different than mine but this may help others or spur a better solution. I was added to a dev team to polish up an app already styled using LESS. I favor SASS and tried to use ember-cli-sass alongside ember-cli-less without any success.
You may want to look further into Ember-Cli's add.import
By adding your input configurations to ember-cli-build.js with the above, you can leverage either your bower-components directory (if used) or vendor directory, to import a compiled CSS doc (from Sass source files) that will build alongside the project quite nicely with a simple sass --watch <input:output> command.
The LESS files are ultimately compiled to app.css, and your SASS files to vendor.css (make sure you link to the stylesheet in your index page/template).

Creating a new cocoapods pod

I'm trying to create my first pod, and, as per the recommendation on the website, am doing so at the command line with pod lib create <mylib>. The trouble is lib create assumes I want to create an iOS library, when in fact I'm developing for OS X. I've grep'ed my way through the cocoapod files on my computer looking for the template on which the generated project is based, but have come up empty-handed. Does anyone know how I might fiddle with these settings, wherever they are, to get the configuration I'm after?
If you already have your library created and just want to create a sample podspec you should use:
pod spec create
Instead. You can also pass this a URL to set that as the source automatically. See
pod spec create --help
For more info.