Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: mfx tree scratchpad #54

Closed
wants to merge 16 commits into from

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Oct 2, 2024

Description

This is a draft PR intended for discussion rather than for merging.

As per #21 and https://jira.slac.stanford.edu/browse/BEAMS-6, this includes a realistic tree example that I used to get a feel for how much the existing structures were usable in a mid-sized close-to-real-world example.

This tree is intended to be part of a larger tree that would help MFX scientists set up their beamline. It would do the menial tasks like set slits to known values, put various devices in or out, and generally get the beamline ready to manually center the beam on the DG1 yag.

In the process, I made some prospective additions and changes to the tree_config submodule. These are all up for discussion and could be kept or discarded as appropriate: for example, perhaps it is more useful to adjust the existing resources rather than add these new resources?

Motivation and Context

We need to try this out on a sizeable real system and this gets us closer.

How Has This Been Tested?

Not at all, I was planning to make a caproto IOC or do some blackboard monkeypatching to play around with the logic in debug.

If any of the additions to tree_config are kept I can add the respective test cases.

Where Has This Been Documented?

Only here and in the jira ticket.

Pre-merge checklist

  • Code works interactively
  • Code follows the style guide
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

@ZLLentz
Copy link
Member Author

ZLLentz commented Oct 2, 2024

Some follow-up tasks for me here:

  • Check what the serialized tree looks like
  • Build a sim IOC or implement the blackboard thing

@ZLLentz
Copy link
Member Author

ZLLentz commented Oct 3, 2024

Attaching SVG render of the tree courtesy of py_trees

In [1]: from mfx_tree import dg1_prep

In [2]: tree = dg1_prep.get_tree()

In [3]: from py_trees.display import render_dot_tree

In [4]: render_dot_tree(tree)
Writing /cds/home/z/zlentz/github/beams/dg1_prep.dot
Writing /cds/home/z/zlentz/github/beams/dg1_prep.png
Writing /cds/home/z/zlentz/github/beams/dg1_prep.svg
Out[4]:
{'dot': '/cds/home/z/zlentz/github/beams/dg1_prep.dot',
 'png': '/cds/home/z/zlentz/github/beams/dg1_prep.png',
 'svg': '/cds/home/z/zlentz/github/beams/dg1_prep.svg'}

dg1_prep

@@ -35,6 +36,15 @@ def get_tree_from_path(path: Path) -> py_trees.trees.BehaviourTree:
return tree_item.get_tree()


def save_tree_to_path(path: Union[Path, str], root: BaseItem):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep, consider separating to own tool, consider extending to read control system and spoof pvs exactly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split off to #57

@@ -155,24 +169,96 @@ def cond_func():
return cond_func


@dataclass
class SequenceConditionItem(BaseItem):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep, might need changes with other pr



@dataclass
class RangeConditionItem(BaseItem):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add, consider alternate implementations (operator or functional on top of ConditionItem) and review

@@ -236,18 +322,38 @@ def work_func(comp_condition: Callable[[], bool]) -> py_trees.common.Status:

@dataclass
class CheckAndDoItem(BaseItem):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submit as own PR, discuss later

Comment on lines +472 to +473
AnyConditionItem = Union[ConditionItem, SequenceConditionItem, RangeConditionItem, UseCheckConditionItem]
AnySequenceItem = Union[SequenceItem, SequenceConditionItem]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep, document interface

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start examples folder???

ZLLentz added a commit to ZLLentz/BEAMS that referenced this pull request Oct 17, 2024
@ZLLentz ZLLentz mentioned this pull request Oct 17, 2024
11 tasks
ZLLentz added a commit to ZLLentz/BEAMS that referenced this pull request Oct 17, 2024
ZLLentz added a commit to ZLLentz/BEAMS that referenced this pull request Oct 17, 2024
ZLLentz added a commit to ZLLentz/BEAMS that referenced this pull request Oct 17, 2024
@ZLLentz ZLLentz mentioned this pull request Oct 17, 2024
8 tasks
ZLLentz added a commit that referenced this pull request Oct 18, 2024
ENH: add test ioc generator from #54
ZLLentz added a commit that referenced this pull request Oct 18, 2024
ZLLentz added a commit that referenced this pull request Nov 4, 2024
ENH: implement SequenceConditionItem from #54
@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 4, 2024

All composite PRs from this one are merged
But I will need to create one final PR to include the mfx tree as an example

I think I'll also wait on a potential impending comparisons rework to handle the range and/or isclose case

@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 8, 2024

It is now time to make the mfx tree examples PR!
Once that PR is up I will close this one

@ZLLentz
Copy link
Member Author

ZLLentz commented Nov 8, 2024

Closing now that #68 exists

@ZLLentz ZLLentz closed this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant