tianyunperfect 2 tahun lalu
induk
melakukan
8ff07844db
4 mengubah file dengan 84 tambahan dan 3 penghapusan
  1. 24 0
      invoke.py
  2. 20 0
      invoke1.py
  3. 1 2
      kafka_topic.py
  4. 39 1
      project-test/bigtree-aircp/debug.py

+ 24 - 0
invoke.py

@@ -0,0 +1,24 @@
+import requests
+
+cmd_str = """
+def factorial(num):
+    fact=1
+    for i in range(1,num+1):
+        fact = fact*i
+    return fact
+"""
+
+print(requests.post("http://172.18.205.202:8000/exec", json={
+    "function_str": cmd_str,
+    "call_str": "factorial(num)",
+    "param_dict": {
+        "num": 3
+    }
+}).json())
+
+# 第一个参数:函数字符串
+# 第二个参数:函数里的名字和参数
+# 第三个参数:入参,以dict形式传递
+
+# 返回值
+{'code': 200, 'res': 6}

+ 20 - 0
invoke1.py

@@ -0,0 +1,20 @@
+import requests
+
+cmd_str = """
+def run(kwargs):
+    import numpy as np
+    from sklearn import preprocessing
+    x = kwargs['x']
+    min_max_scaler = preprocessing.MinMaxScaler()
+    x_minmax = min_max_scaler.fit_transform(np.array(x).reshape(-1, 2))
+    return x_minmax
+"""
+s = [[1, 20, 30, 40, 5, 6, 7, 8, 9, 10], [1, 20, 30, 40, 5, 6, 7, 8, 9, 10]]
+kkk = {'x': s}
+print(requests.post("http://172.18.248.152:8000/exec", json={
+    "function_str": cmd_str,
+    "call_str": "run(kwargs)",
+    "param_dict": {
+        "kwargs": kkk
+    }
+}).json())

+ 1 - 2
kafka_topic.py

@@ -22,7 +22,7 @@ client = pykafka.KafkaClient(hosts="192.168.3.17:9092")
 print(client.topics)
 for i in client.brokers.values():
     try:
-        i.create_topics(topic_reqs=(Topic("kafeidou1"),))
+        i.create_topics(topic_reqs=(Topic("tag_sink_topic"),))
     except Exception as e:
         if re.search("41", str(e)):
             print("该broker 不是 leader,交由下一个broker创建")
@@ -34,5 +34,4 @@ for i in client.brokers.values():
             break
         else:
             raise e
-
 print(client.topics)

+ 39 - 1
project-test/bigtree-aircp/debug.py

@@ -2,7 +2,7 @@ import unittest
 
 import requests
 
-from util import req, reqGet
+from util import req, reqGet, reqForm
 
 
 class MyTest(unittest.TestCase):
@@ -24,3 +24,41 @@ class MyTest(unittest.TestCase):
 
         res = reqGet("https://edsp.rxdptest.k5.bigtree.tech/api/rxdp-xdata-web/dataSource/pageList", {})
         print(len(res['data']))
+
+    def testhttp(self):
+        req("https://httpbin.org/post",
+            {"username": "刘学良", "password": "lxl123456", "type": "account"})
+
+    # 原子标签
+    def testComputer(self):
+        reqForm("http://localhost:8080/test/dealWithTagCompute", {
+            "computeType": 3,
+            "dataSourceCode": "mysqlTestHu123",
+            "dataSourceType": "mysql",
+            "dimensionNo": "10449",
+            "dimensionsName": "amount",
+            "entityName": "实体测试HU421445",
+            "entityNo": "EN882632280592436445",
+            "primaryKey": "projectcode",
+            "primaryTableName": "shopping",
+            "tagName": "采购类型222",
+            "tagNo": "TAG16693657062277747"
+        })
+
+    # 衍生标签
+    def testComputer2(self):
+        reqForm("http://localhost:8080/test/dealWithTagCompute",
+                {"computeType": 1, "dataSourceCode": "mysqlTestHu123", "dataSourceType": "mysql",
+                 "entityName": "mysqlTestShopping33333(mysql数据源)", "entityNo": "EN875254841037837824",
+                 "packageId": "rxdp/mySqlShoppingTest112", "primaryKey": "projectcode", "primaryTableName": "shopping",
+                 "statisticsCycle": "year", "statisticsCycleTime": "createtime",
+                 "tagName": "衍生标签测试多数据源mysql33333", "tagNo": "TAG16674623867383022", "timeStyle": "TS2"})
+
+    # sql标签
+    def testComputer3(self):
+        reqForm("http://localhost:8080/test/dealWithTagCompute",
+                {"computeType": 2, "dataSourceCode": "mysqlTestHu123", "dataSourceType": "mysql",
+                 "entityName": "mysql实体HU123", "entityNo": "EN879274694203750264", "primaryKey": "business_code",
+                 "primaryTableName": "shopping",
+                 "tagCompuleSql": "SELECT projectcode AS businessCode,amount AS tagValue FROM shopping LIMIT ${startNum},${endNum}",
+                 "tagName": "SQL标签HU1112", "tagNo": "TAG16684123244372739"})