Skip to content

Commit

Permalink
Issue 546c: add fixes for auto grouping metadata (#549)
Browse files Browse the repository at this point in the history
* improve autogrouping

* fixes for auto grouping
  • Loading branch information
jkotan authored Dec 18, 2023
1 parent e384b28 commit c5422d4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
6 changes: 4 additions & 2 deletions nxstools/pyeval/scdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import socket
import tango
import json
import time

# from sardana.macroserver.macro import Macro


Expand Down Expand Up @@ -104,13 +106,13 @@ def append_scicat_dataset(macro, status_info=True):
cgrp = sm[fdir]
if cgrp != scanname:
commands.append("__command__ stop")
commands.append(cgrp)
commands.append("%s:%s" % (cgrp, time.time()))
commands.append("__command__ start %s" % scanname)
else:
commands.append("__command__ start %s" % scanname)
commands.append(sname)
commands.append("__command__ stop")
commands.append(scanname)
commands.append("%s:%s" % (scanname, time.time()))
commands.append("__command__ start %s" % scanname)
sname = "\n".join(commands)

Expand Down
83 changes: 45 additions & 38 deletions test/NXSCreatePyEvalH5Cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3055,18 +3055,20 @@ def test_scingestor_append_scicat_dataset_agroup_new(self):

try:
result = scdataset.append_scicat_dataset(macro)
self.assertEqual("__command__ start mytest\n"
"mytest_00123\n"
"__command__ stop\n"
"mytest\n"
"__command__ start mytest", result)
self.assertEqual(macro.log,
["Appending '__command__ start mytest\n"
'mytest_00123\n'
'__command__ stop\n'
'mytest\n'
"__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst" % cwd])
sres = result.split("\n")
self.assertEqual("__command__ start mytest", sres[0])
self.assertEqual("mytest_00123", sres[1])
self.assertEqual("__command__ stop", sres[2])
self.assertTrue(sres[3].startswith("mytest:"))
self.assertEqual("__command__ start mytest", sres[4])
sres = macro.log[0].split("\n")
self.assertEqual("Appending '__command__ start mytest", sres[0])
self.assertEqual("mytest_00123", sres[1])
self.assertEqual("__command__ stop", sres[2])
self.assertTrue(sres[3].startswith("mytest:"))
self.assertEqual("__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst"
% cwd, sres[4])
finally:
if os.path.isfile("%s/scicat-datasets-00000000.lst" % (cwd)):
os.remove("%s/scicat-datasets-00000000.lst" % (cwd))
Expand All @@ -3088,22 +3090,24 @@ def test_scingestor_append_scicat_dataset_agroup_old(self):

try:
result = scdataset.append_scicat_dataset(macro)
self.assertEqual("__command__ stop\n"
"oldtest\n"
"__command__ start mytest\n"
"mytest_00123\n"
"__command__ stop\n"
"mytest\n"
"__command__ start mytest", result)
self.assertEqual(macro.log,
["Appending '__command__ stop\n"
"oldtest\n"
"__command__ start mytest\n"
'mytest_00123\n'
'__command__ stop\n'
'mytest\n'
"__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst" % cwd])
sres = result.split("\n")
self.assertEqual("__command__ stop", sres[0])
self.assertTrue(sres[1].startswith("oldtest:"))
self.assertEqual("__command__ start mytest", sres[2])
self.assertEqual("mytest_00123", sres[3])
self.assertEqual("__command__ stop", sres[4])
self.assertTrue(sres[5].startswith("mytest:"))
self.assertEqual("__command__ start mytest", sres[6])
sres = macro.log[0].split("\n")
self.assertEqual("Appending '__command__ stop", sres[0])
self.assertTrue(sres[1].startswith("oldtest:"))
self.assertEqual("__command__ start mytest", sres[2])
self.assertEqual("mytest_00123", sres[3])
self.assertEqual("__command__ stop", sres[4])
self.assertTrue(sres[5].startswith("mytest:"))
self.assertEqual("__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst"
% cwd, sres[6])
finally:
if os.path.isfile("%s/scicat-datasets-00000000.lst" % (cwd)):
os.remove("%s/scicat-datasets-00000000.lst" % (cwd))
Expand All @@ -3125,16 +3129,19 @@ def test_scingestor_append_scicat_dataset_agroup_update(self):

try:
result = scdataset.append_scicat_dataset(macro)
self.assertEqual("mytest_00123\n"
"__command__ stop\n"
"mytest\n"
"__command__ start mytest", result)
self.assertEqual(macro.log,
["Appending 'mytest_00123\n"
'__command__ stop\n'
'mytest\n'
"__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst" % cwd])
sres = result.split("\n")
self.assertEqual("mytest_00123", sres[0])
self.assertEqual("__command__ stop", sres[1])
self.assertTrue(sres[2].startswith("mytest:"))
self.assertEqual("__command__ start mytest", sres[3])
sres = macro.log[0].split("\n")
self.assertEqual("Appending 'mytest_00123", sres[0])
self.assertEqual("__command__ stop", sres[1])
self.assertTrue(sres[2].startswith("mytest:"))
self.assertEqual("__command__ start mytest' to "
"%s/scicat-datasets-00000000.lst"
% cwd, sres[3])

finally:
if os.path.isfile("%s/scicat-datasets-00000000.lst" % (cwd)):
os.remove("%s/scicat-datasets-00000000.lst" % (cwd))
Expand Down

0 comments on commit c5422d4

Please sign in to comment.