Skip to content

Commit fd77777

Browse files
committed
Rclient and Rwrapper
1 parent 96aa190 commit fd77777

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

server/preprocessing/other-scripts/run_base_contentproviders.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ renv::restore(lockfile = '../renv.lock')
99
Sys.setlocale(category="LC_ALL", locale = "en_US.UTF-8")
1010

1111
library(jsonlite)
12+
library(rbace)
1213
library(logging)
1314

1415
source('utils.R')

server/workers/base/src/base.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import json
23
import subprocess
34
import pandas as pd
@@ -53,11 +54,12 @@ def execute_search(self, params):
5354
raise
5455

5556
def get_contentproviders(self):
56-
cmd = [self.command, "run_base_contentproviders.R", self.wd]
57+
runner = os.path.abspath(os.path.join(self.wd, "run_base_contentproviders.R"))
58+
cmd = [self.command, runner, self.wd]
5759
try:
5860
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
5961
encoding='utf-8')
60-
stdout, stderr = proc.communicate(json.dumps({}))
62+
stdout, stderr = proc.communicate()
6163
output = [o for o in stdout.split('\n') if len(o) > 0]
6264
error = [o for o in stderr.split('\n') if len(o) > 0]
6365
raw = json.loads(output[-1])
@@ -66,7 +68,7 @@ def get_contentproviders(self):
6668
else:
6769
contentproviders = pd.DataFrame(raw)
6870
res = {}
69-
res["contentproviders"] = contentproviders
71+
res["contentproviders"] = contentproviders.to_json(orient='records')
7072
return res
7173
except Exception as e:
7274
self.logger.error(e)
@@ -93,10 +95,7 @@ def run(self):
9395
try:
9496
res = self.get_contentproviders()
9597
res["id"] = k
96-
if res.get("status") == "error" or params.get('raw') is True:
97-
self.redis_store.set(k+"_output", json.dumps(res))
98-
else:
99-
self.redis_store.rpush("input_data", json.dumps(res).encode('utf8'))
98+
self.redis_store.set(k+"_output", json.dumps(res))
10099
except Exception as e:
101100
self.logger.exception("Exception during retrieval of contentproviders.")
102101
self.logger.error(params)

0 commit comments

Comments
 (0)