Thursday, October 25, 2018

setup AzureML dev environment and deploy machine learning model into AKS


Azure Container Service (ACS) is  now Azure Kubernetes Service (AKS)Applications in ACS can be migrated into AKS. MS document is scattered here and there and applied to different version of services. Below is a collection of documents that help to deploy a python machine learning model into AKS as micro service. Below is collection of tutorials. By following them, we can successfully deploy a machine learning model into AKS as web service. 

  1. Configure a development environment 
  2. training a model . if run into package missing error, install them in conda env. For example, conda install matplotlib
  3. following this tutorial to deploy model into AKS
  4. following this tutorial to consume an Azure Machine Learning Web service 
  5. following this tutorial to troubleshooting image/service building error. 


Comments:
  1.  AZML service API does not check the conflict of the image/service name? It looks like Azure just silently created image/service with same name different version number. 
  2. There is no sophisticated authentication and authorization configuration. In class azureml.core.webservice.AksWebservice.deploy_configuration, we can see it has primary key and secondary key parameter. But, it is not enough to fit real life life projects.  Probably, it is because those services are always supposed to be deployed as micro service in a private sub-net? Something like OAuth 2.0 should be implemented and allow user to configure authentication and authorization in Azure portal.
  3. ... more

Wednesday, October 17, 2018

Prevent joomla tinyMCE editor from not displaying image when copy paste content from other website.


I have a knowledge base site built with joomla. Recently, I found images does not shown when we copy&paste web page content from other sites.

This happens because original web pages put crossorigin="anonymous" in their tags. So, as long as joomla tinyMCE filters out this img attributes, those images will be shown again.

To solve this, a quick walk around is finding an tinyMCE plugin and register it in joomla. this plugin will filter out crossorigin attribute when content is pasted into tinyMCE textarea. As a quick dirty solution, I use tinyMCE paste plugin found in plugins directory. And modified two places as below.





java script

Open file:
/var/www/html/media/editors/tinymce/plugins/paste/plugin.min.js


Add below content marked as red,

function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) {
        var content, isPlainTextHtml;
        if (hasContentType(clipboardContent, 'text/html')) {
          content = clipboardContent['text/html'];
        } else {
          content = pasteBin.getHtml();
          internal = internal ? internal : InternalHtml.isMarked(content);
          if (pasteBin.isDefaultContent(content)) {
            plainTextMode = true;
          }
        }
        content = Utils.trimHtml(content);
        //should use Dom parser for robust coding. 
        content = content.replace(/crossorigin=\"anonymous\"/gi,'');

    



chown apache:apache plugin.min.js


sudo chmod 644 plugin.min.js


PHP

Open below file,
/var/www/html/plugins/editors/tinymce/tinymce.php

Add below content marked as red,

// Drag and drop Images
        $allowImgPaste = false;
        $dragdrop      = $levelParams->get('drag_drop', 1);

        $externalPlugins['jpaste'] = JUri::root() . 'media/editors/tinymce/plugins/paste/plugin.min.js'; 



 $externalPlugins = array(
                array('jdragdrop' => JUri::root() . 'media/editors/tinymce/js/plugins/dragdrop/plugin.min.js'),
                array('jpaste' => JUri::root() . 'media/editors/tinymce/plugins/paste/plugin.min.js'),
            );



Above is just a quick dirty walk around. Creating a dedicate tinyMCE plugin for filtering should be a better neat solution.