Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Jan 12, 2025
2 parents 067f4e8 + 5fce896 commit 4cd1ba1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions shuffle-tools/1.2.0/run.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Build testing
NAME=frikky/shuffle:shuffle-tools_1.1.0
NAME=frikky/shuffle:shuffle-tools_1.2.0
docker rmi $NAME --force
docker build . -t frikky/shuffle:shuffle-tools_1.1.0
docker build . -t frikky/shuffle:shuffle-tools_1.2.0

# Run testing
#docker run -e SHUFFLE_SWARM_CONFIG=run -e SHUFFLE_APP_EXPOSED_PORT=33334 frikky/shuffle:shuffle-tools_1.1.0
Expand Down
26 changes: 21 additions & 5 deletions shuffle-tools/1.2.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,7 @@ def escape_html(self, input_data):

def check_cache_contains(self, key, value, append):
org_id = self.full_execution["workflow"]["execution_org"]["id"]
url = "%s/api/v1/orgs/%s/get_cache" % (self.url, org_id)
data = {
"workflow_id": self.full_execution["workflow"]["id"],
"execution_id": self.current_execution_id,
Expand All @@ -1815,6 +1816,7 @@ def check_cache_contains(self, key, value, append):
"search": str(value),
"key": key,
}
directcall = False

allvalues = {}
try:
Expand Down Expand Up @@ -1855,6 +1857,11 @@ def check_cache_contains(self, key, value, append):
#allvalues = get_response.json()
allvalues = self.shared_cache

if "success" not in allvalues:
get_response = requests.post(url, json=data, verify=False)
allvalues = get_response.json()
directcall = True

try:
if allvalues["value"] == None or allvalues["value"] == "null":
allvalues["value"] = "[]"
Expand Down Expand Up @@ -1920,7 +1927,7 @@ def check_cache_contains(self, key, value, append):
try:
for item in parsedvalue:
#return "%s %s" % (item, value)
self.logger.info(f"{item} == {value}")
#self.logger.info(f"{item} == {value}")
if str(item) == str(value):
if not append:
try:
Expand Down Expand Up @@ -1972,17 +1979,26 @@ def check_cache_contains(self, key, value, append):
if value not in allvalues["value"] and isinstance(allvalues["value"], list):
self.cache_update_buffer.append(value)
allvalues["value"].append(value)
#set_url = "%s/api/v1/orgs/%s/set_cache" % (self.url, org_id)
#response = requests.post(set_url, json=data, verify=False)
exception = ""
try:
#allvalues = response.json()
# FIXME: This is a hack, but it works
if directcall:
new_value = parsedvalue
if new_value == None:
new_value = [value]

data["value"] = json.dumps(new_value)

set_url = "%s/api/v1/orgs/%s/set_cache" % (self.url, org_id)
response = requests.post(set_url, json=data, verify=False)
allvalues = response.json()

#return allvalues

return {
"success": True,
"found": False,
"reason": "Appended as it didn't exist",
"reason": f"Appended as it didn't exist",
"key": key,
"search": value,
"value": parsedvalue,
Expand Down

0 comments on commit 4cd1ba1

Please sign in to comment.