MDSplus/mdsplus

TCL's `set current` and `show current` commands have problems when using the `$default_tree_path`

Closed this issue · 6 comments

Affiliation
MIT PSFC

Version(s) Affected
Found in the current alpha, but surely applies to all other versions.

Platform
Found on Ubuntu 20, but surely applies to all other platforms.

Describe the bug
TCL's set current and show current commands do not work as expected when using the $default_tree_path environment variable.

The issue is that the commands were initially designed assuming just one type of tree per directory, thus the "current shot" is stored in a shotid.sys file in the tree directory. Use of the $default_tree_path can place many different types of trees in a directory, however the directory will only have a single shotid.sys file. And because the shotid.sys only contains a single number, the set current and show current commands don't work as expected.

To Reproduce
This example illustrates the problem.

$ mkdir /tmp/trees
$           
$ export default_tree_path=/tmp/trees
$        
$ mdstcl
TCL> edit apple /shot=100 /new
TCL> add node num1 /usage=numeric
TCL> write
TCL> close
TCL>
TCL> edit grape /shot=100 /new
TCL> add node num1 /usage=numeric
TCL> write
TCL> close
TCL>
TCL> edit pear /shot=100 /new
TCL> add node num1 /usage=numeric
TCL> write
TCL> close
TCL> 
TCL> set current apple 777
TCL> show current apple
Current shot is 777
TCL> show current grape
Current shot is 777
TCL> show current pear
Current shot is 777
TCL>
TCL> set current grape 222
TCL> show current apple
Current shot is 222
TCL> show current grape
Current shot is 222
TCL> show current pear
Current shot is 222
TCL> 
TCL> set current pear 555
TCL> show current apple
Current shot is 555
TCL> show current grape
Current shot is 555
TCL> show current pear
Current shot is 555
TCL>
TCL> # expected output is apple=777, grape=222, pear=555
TCL>

Expected behavior
The set current and show current commands should only apply to the specified type of tree.

One solution is to change the shotid.sys file so it contains a dictionary of key-value pairs.

An alternate solution is to leave the code as is and fix the documentation for the set current and shot current commands (i.e., explain how the commands work when using the $default_tree_path environment variable).

Screenshots
n/a

Additional context
This bug was found while investigating Issue #2684.

Hi there,
I think the issue is not $default_tree_path, but rather the fact that it points to a single folder. It was designed to be used with the $t variable. e.g. "default_tree_path=/trees/$t". This will expand to different folders base on the treename and should hence have a proper behaviour for current shot. It is a short hand for "tree1_path=/trees/tree1", "tree2_path=/trees/tree2", etc.

I think @zack-vii is correct. I'm getting the expected behavior with my trees...

junior git:(main) ✗ cat /etc/bigboy_trees.conf
# default tree server
JUNIOR_TREE_SERVER ""
JUNIOR_ARCH_SERVER ""

default_tree_path       $JUNIOR_TREE_SERVER/scratch/trees/junior/test/~t/
default_tree_path       $JUNIOR_TREE_SERVER/scratch/trees/junior/new/~t/ >;
default_tree_path       $JUNIOR_ARCH_SERVER/scratch/trees/junior/archives/~i~h/~g~f/~e~d/~t/ >;
default_tree_path       $JUNIOR_TREE_SERVER/scratch/trees/junior/models/~t/ >;

default_tree_path       /scratch/trees/ldx/new/~t/ >;
default_tree_path       /scratch/trees/ldx/archives/~i~h/~g~f/~e~d/~t/ >;
default_tree_path       /scratch/trees/ldx/models/~t/ >;

junior git:(main) ✗ mdstcl
TCL> show current junior
Current shot is 240202003
TCL> show current ldx
Current shot is 140530031

Hi @zack-vii and @dgarnier,

I concur with both of you.

The conclusion then is that this doesn't require a code fix, but rather a fix to the documentation on the MDSplus.org web site. It should have a sentence or two explaining that the usage as shown in the To Reproduce section above (first post), is unsupported.

NOTE:
Found this issue because there are some use cases (debugging, experimenting, training) when it is useful to create a handful of dinky trees (of different types) in a single directory. Which is why I wasn't including ~t in my default_tree_path.

The documentation should state that for production data acquisition systems it is recommended that default_tree_path be defined with ~t as the last part of the path. And that TCL's set/show current only supports one tree type per folder.

I added a note to deault_tree_path under Tree Access. if that is sufficient you may close the issue. cheers

Also added the following comments to the Wiki's Documentation : Reference : TCL sections for SET CURRENT and SHOW CURRENT.

Note: The SET CURRENT command assumes that there is only one type of tree in a directory.  (If multiple tree paths point to the same directory, SET CURRENT can produce unexpected results.)

Note: The SHOW CURRENT command assumes that there is only one type of tree in a directory.  (If multiple tree paths point to the same directory, SHOW CURRENT can produce unexpected results.)

The documentation changes can be found on these three pages:
default_tree_path
SET
SHOW

Hi @zack-vii and @dgarnier,

Thanks for your help with this issue. All documentation changes have been made, so now closing this issue.