madlib 集成 hasura graphql-engine 试用
madlib 可以让我们直接在sql 中进行机器学习,集成了强大的sql 能力,以及分析能力,后边会尝试
集成graphql engine ,让功能更强大
docker 镜像准备
使用了一个别人的写好的,也可以参考官方提供的,就是镜像包有点大
- docker-compose 文件
version: '2'
services:
db:
container_name: madlib-postgres
build:
context: .
dockerfile: postgres/Dockerfile
environment:
- PG_MODE=primary
- PG_PRIMARY_USER=postgres
- PG_PRIMARY_PASSWORD=postgres
- PG_DATABASE=sample
- PG_USER=user
- PG_PASSWORD=user
- PG_ROOT_PASSWORD=root
- PG_PRIMARY_PORT=5432
restart: always
ports:
- 5432:5432
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- db
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha30
ports:
- "9090:8080"
depends_on:
- db
environment:
- "POSTGRES_PASSWORD:postgres"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://postgres:root@db:5432/sample serve --enable-console;
"
networks:
default:
driver: bridge
ipam:
driver: default
config:
- subnet: 180.16.0.0/16
gateway: 180.16.0.1
- madlib pg dockerfile
FROM crunchydata/crunchy-postgres:centos7-10.5-2.1.0
USER root
RUN yum -y update; yum clean all
RUN yum -y install postgresql10-plpython supervisor; yum clean all
### Get postgres specific add-ons
RUN yum update -y && yum install -y \
git \
gcc \
wget \
postgresql10-devel \
openssl \
m4 \
vim \
flex \
bison \
graphviz \
java \
epel-release \
python-devel
RUN yum install -y python-pip
ENV PATH="$PATH:/usr/pgsql-10/bin"
RUN pip install awscli pygresql paramiko --upgrade
RUN mkdir -p /src/madlib
COPY ./data/apache-madlib-1.15.1-bin-Linux.rpm /src/madlib
RUN yum install -y /src/madlib/apache-madlib-1.15.1-bin-Linux.rpm --nogpgcheck
USER 26
EXPOSE 5432
CMD ["/opt/cpm/bin/start.sh"]
启动&&初始化环境
- 启动
docker-compose build && docker-compose up -d
- 初始化
docker-compose exec db bash
/usr/local/madlib/bin/madpack -p postgres -c postgres/root@localhost:5432/sample install
/usr/local/madlib/bin/madpack -p postgres -c postgres/root@localhost:5432/sample install-check
- 访问
默认账户信息为 postgres root sample - 添加一个简单的数据函数测试
创建表
CREATE TABLE array_tbl (
id integer,
array1 integer[],
array2 integer[]
);
添加数据
INSERT INTO "public"."array_tbl"("id","array1","array2")
VALUES
(1,E'{1,2,3,4,5,6}',E'{6,5,4,3,2,1}'),
(2,E'{1,1,0,0,99,8}',E'{0,0,0,-5,2,1}');
使用数组函数:
说明:主要使用了madlib 的数组最大以及最小函数
select id,madlib.array_min(array1) min, madlib.array_max(array1) max from array_tbl
结果
graphql 引擎使用
- 打开地址
http://localhost:9090
效果
- 集成
为了方便使用计算的结果,我们使用了试图进行扩展 - 查询madlib 的结果数据
说明
这个只是简单的试用,试用上madlib 的功能还是很强大的,同时对于graphql engine 的扩展,我们有好多种
方法,这个只是一种简单的方式,但同时也无法使用强大的weebhook 等功能了(view 的原因)
参考资料
https://github.com/rongfengliang/docker-madlib
madlib 集成 hasura graphql-engine 试用的更多相关文章
- hasura graphql server event trigger 试用
hasura graphql server 是一个很不错的graphql 引擎,当前版本已经支持event triiger 了 使用此功能我们可以方便的集成webhook功能,实现灵活,稳定,快捷的消 ...
- hasura graphql server 集成gatsby
hasura graphql server 社区基于gatsby-source-graphql 开发了gatsby-postgres-graphql 插件, 可以快速的开发丰富的网站 基本使用 安装h ...
- 通过torodb && hasura graphql 让mongodb 快速支持graphql api
torodb 可以方便的将mongo 数据实时同步到pg,hasura graphql 可以方便的将pg 数据暴露为graphql api,集成在一起真的很方便 环境准备 docker-compose ...
- hasura graphql subscriptions 使用
subscriptions graphql 的一项实时数据推送的功能,还是很方便的,自己在直接使用subscriptions-transport-ws npm 包 的时候运行一直有错误(主要是依赖 ...
- Hasura GraphQL schema 生成是如何工作的
不像大部分的graphql 引擎,使用标准的graphql 规范的处理模型,Hasura graphql 不存在resolver 的概念(实际上是有的,只是转换为了sql语法) 以下是Hasura g ...
- hasura graphql auth-webhook api 说明
hasura graphql 生产的使用是推荐使用webhook 进行角色访问控制的,官方同时提供了一个nodejs 的简单demo 代码 git clone https://github.com/h ...
- hasura graphql pg 自定义函数的使用
hasura graphql 的安装可以参考相关项目 创建函数 数据表创建 CREATE TABLE sql_function_table ( id SERIAL PRIMARY KEY, inp ...
- hasura graphql server 集成gitlab
默认官方是提供了gitlab 集成的demo的,但是因为gitlab 一些版本的问题, 跑起来总有问题,所以查找相关资料测试了一个可以运行的版本 项目使用docker-compose 运行 参考 ht ...
- hasura graphql 集成pipelinedb测试
实际上因为pipelinedb 是原生支持pg的,所以应该不存在太大的问题,以下为测试 使用doker-compose 运行 配置 docker-compose 文件 version: '3.6' s ...
随机推荐
- base64加密解密c++代码
关于base64加密解密代码: 程序运行功能请自行查看main函数: #include <stdio.h> #include <string.h> #include <a ...
- 手机号的 AES/CBC/PKCS7Padding 加解密
前言:接口中上次的手机号码和密码是传入的加密的,模拟自动化的时候也需要先对数据进行加密 1.各种语言实现 网上已经各种语言实现好的AES加密,可以点击查看:http://outofmemory.cn/ ...
- centos服务器删除/usr目录怎么办
凉拌 两种方法: 第一:重装系统,因为你的大部分命令使用不了了,如果你的服务器还有应用程序在跑,那你的服务也会有问题,因为一些服务的lib包也会放在此目录下,貌似需要重新装才可以 第二:利用ios镜像 ...
- delphi reintroduce作用
当在子类中重载或者重新声明父类的虚方法时,使用 reintroduce 关键字告知编译器,可以消除警告信息. 如: TParent = class procedure proc;virtual; ...
- django本身提供了runserver,为什么不能用来部署(runserver与uWSGI的区别)
runserver方法是调试django时经常用到的运行方式,它使用django自带的. WSGI Server 运行,主要在测试和开发使用,并且runserver 开启的方式也是单线程. uWSGI ...
- python 常用的高阶函数
前言 高阶函数指的是能接收函数作为参数的函数或类:python中有一些内置的高阶函数,在某些场合使用可以提高代码的效率. map() map函数可以把一个迭代对象转换成另一个可迭代对象,不过在pyth ...
- 58-63用ssh远程连接linux系统
一.注意 在CentOS7.6中,ifconfig来查询IP已经不再适用,要用ip add 二.vim编辑器 编辑:按[i]键可以进入到编辑状态,显示insert这样的字眼就对了 退出:按esc退出编 ...
- MAVEN JDK版本配置
使用maven的时候,默认会使用1.5版本的JDK,并且也是编译成1.5的,我的电脑里面用的JDK是1.7的,1.8也出来了,没理由还用1.5的吧!所以我手动改成了1.7,郁闷的是,每次 maven- ...
- Python 默认值字典
from collections import defaultdict # 默认值字典 dd = defaultdict(lambda: "胡辣汤") # callable 可调用 ...
- Spring Boot 揭秘与实战(一) 快速上手
文章目录 1. 简介 1.1. 什么是Spring Boot 1.2. 为什么选择Spring Boot 2. 相关知识 2.1. Spring Boot的spring-boot-starter 2. ...