(09-24-2020 01:05 PM)zhihao Wrote: [ -> ]talk2thinker.sh
This is not the best name. But let's tolerate it.
Quote:
Code:
work() {
read $newcasepfn till meet blank line
tellThinker()
getresults()
}
tellThinker() informs think about the request.
Code:
$tspfn: sage tasks
tellThinker() {
set $casecnt as the number of cases
switch $casetype {
case "insert":
insert_case()
case "delete":
delete_case()
case "query":
query_case()
}
change user to sage2
use program auntie to register $tspfn
}
tellThinker should really talk to think. But insert() does not. So the name is inadequate. I suggest we rename it to triage() because it differentiates different types of requests and dispatch them to different functions.
RR zhihao
(09-24-2020 01:05 PM)zhihao Wrote: [ -> ]delete_case()
Code:
delete_case() {
clear file $tspfn
set $reqcaseid as request case id
for each case; do
set option $tycano, $reqtype and $reqcaseid for procone.py
done
generate delete success response
}
This is problematic because we give a result '200' before Sage invokes think to run the tasks. It is possible something goes wrong with the delete, but the client receives '200' and think everything is fine. That's a bug.
I am removing the success response.
Then the delete_case function does not return 200, and it is a problem.
Code:
21:40:44 lingu@g1b-2:/home/lingu/forest/prada/prada> make -C procuratorate test
make: Entering directory '/home/lingu/forest/prada/prada/procuratorate'
casecnt before insert: 72
inserting /thinker/storage/soft/bibo/processed/zengxingliang.json
{
"code": 200,
"msg": "ok",
"children": []
}
insert finished
inserted file :/thinker/globe/udata/lingu/testy/procuratorate/tests/typical/73/insert.json
{"type":"insert","query":"","caseid":"","insert":{"keys":[{"key1":"破▒计▒▒信▒系▒","key
casecnt after insert: 73
deleting /thinker/storage/soft/bibo/processed/del_zengxingliang.json
delete finished
file content after deleted
{"type": "","query": "","caseid": "","insert": {"keys": [] }}
make: Leaving directory '/home/lingu/forest/prada/prada/procuratorate'
21:41:06 lingu@g1b-2:/home/lingu/forest/prada/prada>
(09-24-2020 01:05 PM)zhihao Wrote: [ -> ]procone.py
Code:
在某一案例内容中搜索key{1,2,3},构建"keys": []。
Code:
main() {
set $tycajson_pfn as a insert.json
get $reqtype from $tycajson_pfn
if $reqtype is "delete"
delete()
This delete() is different from delete_case() so the name is fine. But I still feel it is too "general" a name. How about we rename it deleteIfMatch?
Quote: else
query()
}
[/code]
procone is quite complex. Pls separate it as a standalone thread.
(09-24-2020 01:05 PM)zhihao Wrote: [ -> ]delete()
I see the implementation is not a function, yet. Pls make it a function soon.
Quote: if $reqcaseid matches $caseid
rename insert.json but don't cover existing file
Just say 'rid --insitu insert.json'
Quote: create empty file insert.json
}
[/code]
It is not a really empty file, is it?
After the match-and-delete, we should generate a result file to report the result of the deletion. If there is no match and no deletion, the result file is a nil file -- a file with zero bytes.
(09-24-2020 10:55 PM)lingu Wrote: [ -> ] (09-24-2020 01:05 PM)zhihao Wrote: [ -> ]delete()
I see the implementation is not a function, yet. Pls make it a function soon.
我这里看procone.py是已经将删除功能设为函数,且今天没有修改过procone.py,也许是我没有push该文件
Code:
...
glog = None
reqcaseid = None
def delete(caseid, tycano, reqcaseid):
global toneroot
tycajson_pfn = toneroot + "/typical/" + tycano + "/insert.json"
glog.flog(" delete() attempts to match and delete " + str(req
glog.flog(" tycajson_pfn " + tycajson_pfn)
glog.flog(" caseid :" + str(caseid) + "reqcaseid: " + str(r
if caseid == reqcaseid:
glog.flog(" caseid == reqcaseid")
cmdline.runOrExit("rid --insitu " + tycajson_pfn )
fw = open(tycajson_pfn,"w")
fw.write("{\"type\": \"\",\"query\": \"\",\"caseid\": \"___\",
{\"keys\": [] }} \n")
fw.close()
def main():
allops = sys.argv[1:]
...
(09-24-2020 08:19 PM)lingu Wrote: [ -> ] (09-24-2020 01:05 PM)zhihao Wrote: [ -> ]talk2thinker.sh
Code:
work() {
read $newcasepfn till meet blank line
tellThinker()
getresults()
}
getresults() may have trouble for insert and delete because they do not generate "results".
将getresults()删除,后面再将其加到query_case()后执行。已更新首文为如下内容:
Code:
work() {
read $newcasepfn till meet blank line
tellThinker()
}
(09-24-2020 08:19 PM)lingu Wrote: [ -> ]Quote:tellThinker() informs think about the request.
Code:
$tspfn: sage tasks
tellThinker() {
set $casecnt as the number of cases
switch $casetype {
case "insert":
insert_case()
case "delete":
delete_case()
case "query":
query_case()
}
change user to sage2
It does not "change user". The program just specify sage_user=sage2, right?
首文修改为
(( change user to sage2 -> set $sage_user as sage2))
(09-24-2020 08:19 PM)lingu Wrote: [ -> ]Quote: use program auntie to register $tspfn
}
We should not register tasks for insert. So I think we need move this 'auntie register' to the functions for query and delete.
--- 20200924/lingu moved the auntie register to functions delete_case() and query_case()
OK, I'll reply headpost and update these two D info in
#22
(09-24-2020 08:22 PM)lingu Wrote: [ -> ] (09-24-2020 07:57 PM)zhihao Wrote: [ -> ] (09-24-2020 07:22 PM)lingu Wrote: [ -> ] (09-24-2020 06:01 PM)zhihao Wrote: [ -> ]在cod://prada内添加了Makefile逻辑,添加maketst.sh。目前make test可测试插入删除。
should move it to dir procuratorate. bibo is not prada.
where is the info about the tests?
在cod://prada/procuratorate/ 内创建Makefile和maketest.sh。
Dont make a big test of all tests. Make small tests and combine them.
I think you can rename maketest.sh to be test_crds.sh -- it creates, reads, deletes and selects a case. The create, read, delete and select ops can be individual tests in their own scripts. The crds test invokes them in sequence.
renamed maketest.sh to test_crds.sh and created file "test_delete.sh test_insert.sh test_read.sh test_select.sh" in cod://prada/procuratorate
(09-24-2020 08:22 PM)lingu Wrote: [ -> ]Quote:maketest.sh D info:
Code:
show case count before insert
send insert request to trajan.d-thinker.org 20050
output inserted case file
show case count after insert
send delete request to trajan.d-thinker.org 20050
RR lingu
OK as the first version. Make sure to ALWAYS RECORD INFO when designing.
No need to specify D info for tests. Just write OMUD together. Create a thread for that.
created in
test_crds.sh -- OMUD
(09-24-2020 08:26 PM)lingu Wrote: [ -> ] (09-24-2020 02:08 PM)zhihao Wrote: [ -> ]tellThinker() informs think about the request.
Code:
tellThinker() {
set $casecnt as the number of cases
switch $casetype {
case "insert":
insert()
case "delete":
delete()
case "query":
query()
}
}
There is a 'select' function.
added a 'select' function to tellThinker()
(09-24-2020 08:26 PM)lingu Wrote: [ -> ]Pls design the 'select' function. You can ask collaborators if you are not sure what 'select' is expected to do.
select function designed as follows:
Code:
select_case() {
clear file $tspfn
set $reqcaseid as request case id
for each case; do
set option $tycano, $reqtype and $reqcaseid for procone.py
done
getresults()
}
RR lingu
(09-24-2020 08:26 PM)lingu Wrote: [ -> ]Pls also add a query test and a select test.
OK
(09-24-2020 10:28 PM)lingu Wrote: [ -> ] (09-24-2020 01:05 PM)zhihao Wrote: [ -> ]talk2thinker.sh
This is not the best name. But let's tolerate it.
Quote:
Code:
work() {
read $newcasepfn till meet blank line
tellThinker()
getresults()
}
tellThinker() informs think about the request.
Code:
$tspfn: sage tasks
tellThinker() {
set $casecnt as the number of cases
switch $casetype {
case "insert":
insert_case()
case "delete":
delete_case()
case "query":
query_case()
}
change user to sage2
use program auntie to register $tspfn
}
tellThinker should really talk to think. But insert() does not. So the name is inadequate. I suggest we rename it to triage() because it differentiates different types of requests and dispatch them to different functions.
RR zhihao
LGTM and updated headpost and cod://prada/procuratorate/talk2thinker.sh
(09-24-2020 10:52 PM)lingu Wrote: [ -> ] (09-24-2020 01:05 PM)zhihao Wrote: [ -> ]procone.py
Code:
在某一案例内容中搜索key{1,2,3},构建"keys": []。
Code:
main() {
set $tycajson_pfn as a insert.json
get $reqtype from $tycajson_pfn
if $reqtype is "delete"
delete()
This delete() is different from delete_case() so the name is fine. But I still feel it is too "general" a name. How about we rename it deleteIfMatch?
OK, updated headpost and cod.
(09-24-2020 10:52 PM)lingu Wrote: [ -> ]Quote: else
query()
}
[/code]
procone is quite complex. Pls separate it as a standalone thread.
created in
procone.py -- OMUD