How to check for Vertex Matching in ArangoDB - arangodb

I have created two collections in ArangoDB, a document collection "Node" and an edge collection "Path". All my nodes have a name attribute and are connected by edges.
My traversal has a variable depth of 1..10, which will find the followings paths:
start - decide
start - decide - execute1
start - decide - execute2
start - decide - execute1 - error
start - decide - execute2 - end
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
start - decide - execute2 - execute3 - end
I tried below query to find paths that end with an end or error node:
FOR v, e, p IN 1..10 OUTBOUND 'Node/start_0' Path
OPTIONS { bfs: true}
FILTER (v.name == "end" OR v.name == "error")
RETURN CONCAT_SEPARATOR(' - ', p.vertices[*].name)
It gives me below 4 Results
[
start - decide - execute1 - error
start - decide - execute2 - end
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
start - decide - execute2 - execute3 - end
]
Here i want to do a additional pattern matching check, I want to list results that has particular sequence of vertex in them.
I want to list the result that has sequence decide execute1 execute2 in them
i.e., My result should be as given below:
[
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
]
I tried adding below filter condition to my query but it didnot work
FILTER LIKE(p.vertices[*].name, "%decide - execute1 - execute2%", true)
Can Someone help me on this

I believe this should work if you move the main query into a subquery, and then apply the filter afterwards, e.g. something like:
FOR path IN (
FOR v, e, p IN 1..10 OUTBOUND 'Node/start_0' Path
OPTIONS { bfs: true}
FILTER (v.name == "end" OR v.name == "error")
RETURN CONCAT_SEPARATOR(' - ', p.vertices[*].name)
)
FILTER LIKE(path, "%decide - execute1 - execute2%", true)
RETURN path

Related

RASA 2.8 - Final custom action in rules are not run

I'm trying to setup a bot that takes three inputs, two from buttons, and one from text. Currently, I'm able to pass in all of the required input. However, when it comes time for the final action, the bot does not seem to know what to do, and returns either a greeting or a message that it does not understand me. Is there anything wrong with my rules or domain files?
rule.yml
version: "2.0"
rules:
- rule: Activate conv_get_job_status
steps:
- intent: get_job_query
- action: action_populate_user_bot_info
- action: job_type_selection #this creates a list of buttons for job type selection
- action: job_type_input #job type form, to set job_type slot
- active_loop: job_type_input
- rule: Submit conv_get_job_status
condition:
- active_loop: job_type_input
- active_loop: job_name_and_number_input
steps:
- action: job_type_input
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: job_name_selection #this creates a list of buttons for job name selection
- action: job_name_and_number_input #job name and number form, to set job_name and job number slots
- active_loop: job_name_and_number_input
- action: job_name_and_number_input
- active_loop: null
- slot_was_set:
- requested_slot: null
- action: action_return_job_status #various utterances, currently not called.
testjob_domain.yml
version: '2.0'
entities:
- job_type
- job_name
- job_number
intents:
- get_job_query
actions:
- action_reset_job_type_input
- job_number_query
- utter_ask_job_number
- utter_ask_job_name
- utter_ask_job_type
- action_return_job_status
- job_name_selection
- get_job_status
- action_reset_get_job_status
- job_type_selection
- action_reset_job_name_and_number_input
responses:
utter_ask_job_type:
- text: Select job type
utter_ask_job_name:
- text: Select job name
utter_ask_job_number:
- text: Enter job number
slots:
execute_action:
type: text
job_type:
type: text
job_name:
type: text
job_number:
type: text
forms:
job_type_input:
job_type:
- type: from_text
intent_name: None
job_name_and_number_input:
job_name:
- type: from_text
intent_name: None
job_number:
- type: from_text
intent_name: None
The code for action_return_job_status:
from .action_utils import *
class ActionReturnJobStatus(Action):
def name(self):
return "action_return_job_status"
def run(self, dispatcher, tracker, domain):
logger.info("Action - action_return_job_status")
logger.info("execute_action_slot: "+str(tracker.slots['execute_action']))
record_bot_event(tracker, dispatcher, 'new_session', auth_critical=authorization_critical)
# set auth_critical=True to skip action code execution
if not verifyBAMToken(tracker, dispatcher, auth_critical=authorization_critical):
return
logger.info("RUNNING GET ACTION")#I would expect to see either this in the logs or the utterances. Neither happens
dispatcher.utter_message("RUNNING GET ACTION")
return [SlotSet('latest_faq_question', None), SlotSet('latest_application_name', None)]

github action yaml: how to refer an item in a matrix array?

That's my matrix:
jobs:
check-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
And I have this current conditional (that's working):
if: matrix.python-version == 3.6
How can I replace 3.6 by the first item of my matrix? I mean, how to tell in yaml:
if: matrix.python-version == "the_first_item_from_matrix.python-version"
And no, matrix.python-version[0] (or [1], I don't know how it's indexed) won't work.
The reasoning here is: in some point I will drop 3.6 support and I don't want to remember to remove any 3.6 hardcoded in my workflow.
I propose a simple workaround using the strategy.job-index property. According to the documentation, this property is defined as follows:
The index of the current job in the matrix. Note: This number is a zero-based number. The first job's index in the matrix is 0.
You can use this property to ensure that a step is only executed for the first job in the matrix.
Here is a minimal workflow to demonstrate the idea:
name: demo
on:
push:
jobs:
demo:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.10']
runs-on: ubuntu-latest
steps:
- if: strategy.job-index == 0
run: echo '3.7' && exit 1
- if: strategy.job-index == 1
run: echo '3.10' && exit 1
Here are screenshots to show the result:
Sadly this workaround will get more complicated once we start to work with a matrix that has more than one dimension.

Adding/changing numbers in specific lines

I have a big file with 250,000 lines and I want to change the numbers every 36 lines.
Example of my file:
rankup_cost_increase_percentage: 0.0
removepermission:
- essentials.warps.B
- essentials.warps.C
- essentials.warps.D
- essentials.warps.E
- essentials.warps.F
- essentials.warps.G
- essentials.warps.H
- essentials.warps.I
- essentials.warps.J
- essentials.warps.K
- essentials.warps.L
- essentials.warps.M
- essentials.warps.N
- essentials.warps.O
- essentials.warps.P
- essentials.warps.Q
- essentials.warps.R
- essentials.warps.S
- essentials.warps.T
- essentials.warps.U
- essentials.warps.W
- essentials.warps.X
- essentials.warps.Y
- essentials.warps.Z
executecmds:
- "[CONSOLE] crate give to %player% Legendary 1"
- "[CONSOLE] crate give to %player% Multiplier 1"
- "[player] warp A"
P7437:
nextprestige: P7438
cost: 3.7185E13
display: '&8[&9P7437&8]'
rankup_cost_increase_percentage: 0.0
I want rankup_cost_increase_percentage: 0.0 to increase by 5.0 everytime.
How would I be able to do that?

Make all timestamps in a list have the same format

I have this list and would like for all of the timestamps to have the same format (... = more elements):
timestampList = [...
"8:36 - Appointment1",
"9:21 - Appointment2",
"10:01 - Appointment3",
"11:52 - Appointment4",
"12:18 - Appointment5" ...]
Is there an easy way to make sure all timestamps in the list have the same format(HH:MM)? Is there perhaps a module that makes this possible? I have tried to resolve the problem but couldn't find a way of doing it. I want the list to look like this:
timestampList = [...
"08:36 - Appointment1",
"09:21 - Appointment2",
"10:01 - Appointment3",
"11:52 - Appointment4",
"12:18 - Appointment5" ...]
You can use re.sub and a lookahead regex from the beginning of the line. If we see that the timestamp starts with \d:, then prepend a "0":
>>> import re
>>> [re.sub(r"^(?=\d:)", "0", x) for x in timestamps]
['08:36 - Appointment1', '09:21 - Appointment2', '10:01 - Appointment3', '11:52 - Appointment4', '12:18 - Appointment5']

How to List Recursive Path in ArangoDB

I am trying to do a graph traversal where i want to list only the recursive path
My traversal has a variable depth of 1..10, which will find the followings paths:
1. start - decide - execute1 - end
2. start - decide - execute2 - decide - execute1 - end
3. start - execute3 - end
With the below query:
FOR v, e, p IN 1..10 OUTBOUND 'Node/start_0' Path
FILTER v.name == "end"
RETURN CONCAT_SEPARATOR(' - ', p.vertices[*].name)
Now i want to list only the path that has recursion or loop on it, in this example i want to get only the path 2. start - decide - execute2 - decide - execute1 - end since it goes through decide - execute2 - decide.
I know we can avoid such loop Scenario by setting uniqueVertices: 'path' but how to get only the scenario that has loop in it

Resources