AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

^respond(~topic.rulelabel) failing after ^available(~topic.rulelabel) succeeds
 
 

I am trying to resume processing a topic at a particular point. My strategy is to have a predictable label on a rule in the topic and test to see if that rule exists, if it does then I want to do normal ^respond() processing starting at that point. My topic has keep and repeat in the topic specification. What I am seeing is that the ^respond(~topic.rulelabel) is always failing and I don’t know why.

The documentation for ^respond() states:

If a value designates a labelled or tagged rule (e.g., ~mytopic.mylabel or ~mytopic.1.0) then the system will skip over all rules until it reaches that rule, then begin linear scanning,

The documentation for ^available() state:

Sees if the named rule is available (1) or used up (0). If you supply the optional argument, the function will fail if the rule is not available.

When I run this code:

$$_goal = ^join(%topic RESUME_GOAL)
 ^
log(\n testing to see if $$_goal is available)
 if( ^
available($$_goal optionalfail)){
  
^nofail(TOPIC ^respond($$_goal))
 

which refers to this topic and rule

topic: ~jenkins-jobs-job-builds-getLatestBuild keep repeat (~jenkins_topics get latest last build )

uTRY_MATCH build~)
 ^
addtopic(~)
 $
$_getLatestBuild_Active true

u
END_NON_MATCH ($$_getLatestBuild_Active==null) ^fail(TOPIC)

uRESUME_GOAL () # entry point for control script to retry running this goal
 
^log\n RESUME_GOAL for ~) 

I get this in my trace log.

testing to see if ~jenkins-jobs-job-builds-getlatestbuild.RESUME_GOAL is available
...NOPROBLEM ^log(\n testing to see if $$_goal is availabl) => ``
....If 
....
System call ^available(`~jenkins-jobs-job-builds-getlatestbuild.RESUME_GOAL`)
....
NOPROBLEM ^available(~jenkins-jobs-job-builds-getlatestbuild.) => `1`
.... ^
available PASS-if
...
System call ^nofail(`TOPIC ^respond ( $$_goal )`)
....,.
System call ^respond(`~jenkins-jobs-job-builds-getlatestbuild.RESUME_GOAL`)
....,...
Respond trying ~jenkins-jobs-job-builds-getlatestbuild.RESUME_GOAL
....,.FAILRULE ^respond(~jenkins-jobs-job-builds-getlatestbuild.) => ``
...
NOPROBLEM ^nofail(TOPIC ^respond ( $$_goal )) => ``
...
End If 
 

 
  [ # 1 ]

I believe that I have found a work around!!

I would still like to know why the system behaves as described above.

The work around is.

$$_goal = ^join(%topic RESUME_GOAL)
 ^
log(\n testing to see if $$_goal is available)
 if( ^
available($$_goal optionalfail)){
  
^enable($$_goal)
  ^
nofail(TOPIC ^respond($$_goal))
 


Perhaps the call to ^available() counts as a match and thus turns off the rule.

 

 
  [ # 2 ]

I guess that I don’t have it fixed yet :-(
the below trace shows that the ^available and ^enable work fine but the ^respond is still failing.

?? is there a way to find out exactly why the rule is failing? :topicinfo indicates that the rule is enabled.
?? is there a problem calling ^respond from within an outputmacro: ?

....,....,..........System call ^available(`~jenkins-jobs-job-getjobname.SCAN_MATCH`,`optionalfail`)
....,....,..........
NOPROBLEM ^available(~jenkins-jobs-job-getjobname.SCAN_MATCH) => `1`
....,....,.......... ^
available PASS-if
....,....,.........
System call ^enable(`RULE`,`~jenkins-jobs-job-getjobname.SCAN_MATCH`)
Undoing erase uSCAN_MATCH ( * ) $$_donothing null 
....,....,.........NOPROBLEM ^enable(RULE) => ``
....,....,.........
System call ^nofail(`TOPIC ^respond ( $$_scanrule )`)
....,....,............
System call ^respond(`~jenkins-jobs-job-getjobname.SCAN_MATCH`)
....,....,..............
Respond trying ~jenkins-jobs-job-getjobname.SCAN_MATCH
....,....,............FAILRULE ^respond(~jenkins-jobs-job-getjobname.SCAN_MATCH) => `` 
 

 
  [ # 3 ]

First point, your rule will ALWAYS be available because the topic has KEEP on it.

Second, this simpler example worked for me:

u: (test)  $_goal = ^join(~jenkins . RESUME_GOAL)
if( ^available($_goal optionalfail)){
^nofail(TOPIC ^respond($_goal))
}

topic: ~jenkins keep repeat (get latest last build )
u: TRY_MATCH (  ) bad
u: RESUME_GOAL () we got here

and the code also works from inside an outputmacro.

Now, I’m not sure why you used $$_ as your prefix nor whether that confused the system.  Try my code first, or try your code changing the variable to a simple $_ variable.

 

 
  [ # 4 ]

Bruce,

I am using the $$_var because it is a local temporary variable. I will try with $_.

BTW, is there anyway to get the failure reason or catch the failure in the code at all besides ignoring it using ^nofail?


I ended up having my outputmacro call ^reuse($$_rule) and then had the rule look like this:

uFREE_MATCH regular input matching)
    ^
registergoal(~thistopic)
uNON_MATCH (!~) ^fail(TOPIC)

sRESUME_WORK (?)
    ^
disable(FREE_MATCH
    ^
respond(~) 

 

 

 
  login or register to react