How to use a File Selector with hvplot in a Docker Panel Serve Environment? - holoviews

Similar to this question about this error message I get a
Uncaught (in promise) Error: Error rendering Bokeh model: could not find #53e7b147-e581-431b-90e1-1fe7ade39263 HTML tag
at u (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:585:113)
at n._resolve_root_elements (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:585:621)
at w (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:163:515)
at t.embed_items (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:163:1455)
when running this app
import panel as pn
import glob
file_list = glob.glob( r'/usr/src/app/apps/*.nc' )
def get_comps():
select_file = pnw.Select(name="File", options=file_list).servable(target="sidebar")
#pn.depends(select_file.param.value)
def selected_file(select_file):
return pn.pane.Str(select_file, height=100, sizing_mode='stretch_width')
return [ select_file , selected_file ]
bootstrap = pn.template.BootstrapTemplate(title='Glob Demo')
sfe = get_comps()
bootstrap.sidebar.append(sfe[0])
bootstrap.main.append(sfe[1])
bootstrap.servable()
even though the FileSelector widget sees the files and displays as expected in another example app that is ran with the same panel serve command inside a Docker container that the Glob Demo App is ran with
docker run -p 8066:8000 -v /PATH_TO_APPS/apps:/usr/src/app/apps yp2
I would love to mount a volume when running my Docker Container that I can select a file from and load with Xarray and plot with HvPlot but I am stuck at even selecting a file. I already have the app I want to serve thanks to #Marc and this question.
Panel Version : 0.13.1
OS : Ubuntu
Docker Version : 20.10.17, build 100c701

Related

Airflow - Custom XCom backend on Ubuntu

I'm trying to implement custom XCOM backend.
Those are the steps I did:
Created "include" directory at the main Airflow dir (AIRFLOW_HOME).
Created these "custom_xcom_backend.py" file inside:
from typing import Any
from airflow.models.xcom import BaseXCom
import pandas as pd
class CustomXComBackend(BaseXCom):
#staticmethod
def serialize_value(value: Any):
if isinstance(value, pd.DataFrame):
value = value.to_json(orient='records')
return BaseXCom.serialize_value(value)
#staticmethod
def deserialize_value(result) -> Any:
result = BaseXCom.deserialize_value(result)
result = df = pd.read_json(result)
return result
Set at config file:
xcom_backend = include.custom_xcom_backend.CustomXComBackend
When I restarted webserver I got:
airflow.exceptions.AirflowConfigException: The object could not be loaded. Please check "xcom_backend" key in "core" section. Current value: "include.cust...
My guess is that it not recognizing the "include" folder
But how can I fix it?
*Note: There is no docker. It is installed on a Ubuntu machine.
Thanks!
So I solved it:
Put custom_xcom_backend.py into the plugins directory
set at config file:
xcom_backend = custom_xcom_backend.CustomXComBackend
Restart all airflow related services
*Note: Do not store DataFrames that way (bad practice).
Sources I used:
https://www.youtube.com/watch?v=iI0ymwOij88

Error building webpage: RStudio + blogdown + Ezhil Theme

I am new to blogdown/hugo themes and want to build a webpage using the Ezhil theme with RStudio. I am following the instructions of blogdown.
In particular, after creating the project on RStudio, I am not able to build/serve the site. If I run serve_site(), I obtain
> blogdown::serve_site()
Launching the server via the command:
/Users/brunoconteleite/Library/Application Support/Hugo/0.84.2/hugo server --bind 127.0.0.1 -p 4321 --themesDir themes -t ezhil -D -F --navigateToChanged
Error: Error building site: logged 1 error(s)
Instead, if I run hugo_build(), I obtain
> blogdown::hugo_build()
Start building sites …
hugo v0.84.2-E0C67958+extended darwin/amd64 BuildDate=2021-06-28T10:59:21Z VendorInfo=gohugoio
ERROR 2021/06/29 13:20:37 instagram shortcode: Missing config value for services.instagram.accessToken. This can be set in config.toml, but it is recommended to configure this via the HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN OS environment variable. If you are using a Client Access Token, remember that you must combine it with your App ID using a pipe symbol (<APPID>|<CLIENTTOKEN>) otherwise the request will fail.
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-missing-instagram-accesstoken"]
Total in 40 ms
Error: Error building site: logged 1 error(s)
I tried to add the suggested ignoreErrors = ["error-missing-instagram-accesstoken"] line of code to the config.yalm file but could not address this issue.
You need to turn the TOML code into YAML if your config file has yaml or yml extension.
So, rather than ignoreErrors = ["error-missing-instagram-accesstoken"], add ignoreErrors: "error-missing-instagram-accesstoken" line to your config.yaml file. It should work.

Simple python app deployed but not deployed

I just installed dokku for the first time and I'm struggling with an apparently very simple problem... I made a sample python app that just logs an env variable:
import os
import time
API_TOKEN = os.getenv('API_TOKEN')
while True:
print(f'API_TOKEN is {API_TOKEN}')
time.sleep(1)
pass
With a Procfile as this:
worker: python temp.py
The deploy looks normal and successful, however if I try to look at the logs, dokku says
App <app name> has not been deployed .
Am I missing something very trivial?
Thanks in advance!
By default dokku only scales up the web process if it is present. Any workers or other processes are scaled to 0 otherwise known as "App < app name > has not been deployed"
To deploy your app you need to log onto the box and scale up the worker by running:
dokku ps:scale <app name> worker=1
change 1 to a larger number if you want more workers
If you often deploy the app to different dokku instances and have to search for this solution over and over again you can instead create a file in the root of your app called DOKKU_SCALE. In it you can set the default scale of all the proceses, like so:
worker=1
That reminds me, I need to go do that now. It is driving me nuts.

Application Rapidly Opens and Closes Multiple Consoles Before Opening (PyQt5, Cx_Freeze & Py2Exe)

I'm attempting to freeze my Python application and have been running into the same problem when using both Cx_Freeze and Py2Exe. Once I've built/frozen the code I start up the executable and rapidly about a half dozen consoles flash (open and close rapidly in succession) on the screen until my GUI Window (created using PyQt5) opens. Once the GUI Window is open, everything appears to be operating fine.
Note: Dll Files
There seems to be a common error around DLL files and I've already included a folder called platforms with the qwindows.dll file, as well as the libEGL.dll file directly in the same folder as the executable. I don't believe this is relevant however as I am able to actually see my initial Widget.
Here is my setup.py file for Cx_Freeze:
import sys
from cx_Freeze import setup, Executable
base = 'Win32GUI'
executables = [
Executable('__main__.py', base=base)
]
# Dependencies are automatically detected, but it might need fine tuning.
buildOptions = {"packages": [], "excludes": []}
#serial, requests, idna
setup(name = "Test",
version = "0.1",
description = "Manufacturing Testing Software",
options = dict(build_exe = buildOptions),
executables = executables)
Here is my setup.py file for Py2Exe:
from setuptools import setup
import os
import py2exe
includes = ["sip",
"PyQt5",
"PyQt5.QtCore",
"PyQt5.QtGui",
"PyQt5.QtWidgets",
"PyQt5.QtWebKit",
"PyQt5.QtWebKitWidgets",
"PyQt5.QtWebKitWidgets",
"PyQt5.QtNetwork",
"PyQt5.QtPrintSupport"]
datafiles = [("platforms", [r"C:\Users\allan\AppData\Local\Continuum\Anaconda2\Library\plugins\platforms\qwindows.dll"]),
("", [r"c:\windows\syswow64\MSVCP100.dll",
r"c:\windows\syswow64\MSVCR100.dll",
r"C:\Python36-32\Lib\site-packages\PyQt5\Qt\bin\libEGL.dll"])]
setup(
name='Test',
version='1',
windows=['__main__.py'],
data_files = datafiles,
options={
"py2exe":{
"includes": includes,
}
}
)
The problem was that I invoked certain os.system commands before the main event look so prior to actually opening up a pyqt window, several shells were opening and closing in rapid succession.

How to use the console command DbAcl in CakePHP 2.0

I'm trying to do my first steps with CakePHP 2 console with Leopard and XAMPP but I get many problems which are not clear to me.
In the CakePHP 2.0 guide is written i need to setup correctly /app/Config/database.php to be sure it works, then I've tested it with an user registration and everything works.
Then I've read I can call the command via shell:
$ cake schema create DbAcl
This doesn't work because I must write the right path to the console app, then:
$ /Users/username/.../site.com/lib/Cake/Console/cake schema create DbAcl
After did that I get this error:
Welcome to CakePHP v2.0.4 Console
---------------------------------------------------------------
App : username
Path: /Users/username/
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
/Users/username/Config/Schema/db_acl.php could not be loaded
iMac-Name:~ username$
My CakePHP installation is located in the folder site.com:
site.com/app
site.com/lib
site.com/plugins
site.com/vendors
site.com/etc.
So I did this to change the CakePHP folder to the installation folder named site.com
$ /Users/username/.../site.com/lib/Cake/Console/cake -app /Users/.../site.com
Now I get this message:
Welcome to CakePHP v2.0.4 Console
---------------------------------------------------------------
App : site.com
Path: /Users/.../public_html/site.com/
---------------------------------------------------------------
Current Paths:
-app: site.com
-working: /Users/.../site.com
-root: /Users/.../public_html
-core: /Users/.../site.com/lib
Now if I write
$ /Users/username/.../site.com/lib/Cake/Console/cake schema create DbAcl
I get the wrong original path again with a different error:
Welcome to CakePHP v2.0.4 Console
---------------------------------------------------------------
App : username
Path: /Users/username/
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
/Users/username/Config/Schema/db_acl.php could not be loaded
How can I fix the path correctly?
strange thing, if I set user folder first, it works correctly:
$ cd folder/webserver/public_html/cake-app-folder
$ sudo lib/Cake/Console/cake schema DbAcl
in this way it works perfect
The real reason why many people that want to use Cakephp ACL system face this problem is that they ignore the right position where they should be before execute this command.
If you notice the error message, it says : "/Users/username/Config/Schema/db_acl.php could not be loaded".
Which is normal, actually the db_acl.php file is located in /Users/username/app/Config/Schema/db_acl.php
==> To let cakePhp fetch the file from the right place you have to be positioned in the app folder of your cake project before executing the command (cd folder/webserver/public_html/cake-app-folder in your case or c:\wamp\www\cakeTest\app for a windows project case)
Dr.Lotfi
Coopa' easy'

Resources