BCDA-APS / bluesky_training

Bluesky training, including instrument package
https://bcda-aps.github.io/bluesky_training/
Other
11 stars 0 forks source link

DOC Simpler Hello, World notebook #100

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

The Hello, World example installs the full instrument package. It could be simpler, installing just enough (RunEngine and a databroker temporary catalog) to make the notebook work.

prjemian commented 1 year ago

The quick_hello was developed to demonstrate with the queueserver but there is nothing specific about QS in this module. It could be the basis.

Also, it is another demonstration (but not a tutorial) of a custom device:

prjemian commented 1 year ago

Note that quick_hello is used in the Hello, World notebook.

prjemian commented 1 year ago

Cell In [1] might be replaced with:

import pathlib, sys

sys.path.append(str(pathlib.Path.home() / "bluesky"))

import bluesky
import databroker
from bluesky.callbacks.best_effort import BestEffortCallback

cat = databroker.temp()
RE = bluesky.RunEngine()
RE.subscribe(cat.v1.insert)
RE.subscribe(BestEffortCallback())

and then remove (see note below for where this could be moved) the discussion of logging and its details.

prjemian commented 1 year ago

Also, there is typo on this line:

The data from this run is available until we quite the IPython session

Should use quit instead of quite

prjemian commented 1 year ago

The discussion about logging could be moved into a new notebook in the instrument directory that describes logging in the instrument package. There's some complexity and flexibility in that process.

rodolakis commented 1 year ago

I copied the HelloWorld from /instrument into /turor and added some more detailed explanations (some hidden in pull down menus). The original HelloWorld can be merged into the "Test the New Bluesky Instrument"? (there is a lot of redundancies between the 2 already)

When I tested the notebook to refresh the output, I had to add os.chdir(my_path) since I was in a random directory and %run -i user/quick_hello.py failed. There maybe a more elegant way to do this with pathlib but I could not find it easily.

rodolakis commented 1 year ago

I just realized that the previous version did include a: $ cd /tmp (should have been home instead, as discussed earlier") but that was in the "Installation step" pull down menu, which is why I missed it!

This step should be part of the "start bluesky session" page I mentioned in:

then link that page at the start of HelloWorld. If starting with the correct ipython profile the user should already be in the correct directory. But what about jupyter?

rodolakis commented 1 year ago

@prjemian which makes we wonder, can I "retract" a pull request? (if I want to make more changes in my #100-HelloWorld branch?)

rodolakis commented 1 year ago

Updated comments from last night.

rodolakis commented 1 year ago

Figured out how to cancel my pull request, fixed my path issue (in a much simpler way) and resubmitted.

prjemian commented 1 year ago

can I "retract" a pull request

Yes, in a couple ways. One way is to mark it as a draft, which means do not review or merge it yet. (Implies there is more work that will happen.)

Another way is to close the pull request without merging. This does not delete the branch, just cancels the intent to review and merge the branch at this time. It's the most common way to indicate no more work is being done on this PR. Leave a comment in the PR to describe why. Can always create a new PR for a branch.

Another way is to delete the branch, at which time the PR probably self-destructs since there is, then, no branch to be merged. GitHub might not let you delete a branch (I don't know) which is still part of a PR. The usual process is close the PR(s) first, then delete the branch.

prjemian commented 1 year ago

%run -i user/quick_hello.py failed

You are right. This fails since it tries to run using a file reference. Because the reference is a relative path (which assumes some starting directory), it failed. If an absolute path is used (such as /home/somebody/bluesky/user/quick_hello.py, this part of the notebook will not be general.

I agree the pragmatic correction is to use os.chdir() (or path.os.chdir() to avoid import os)

An alternative is to use %run -im user.quick_hello (loads a Python module instead of a Python file) which assumes:

Might be the better way. I know that the difference between %run -i file.py and %run -im module was not so easy to learn. I like the module way better. Our SPEC users are used to qdo macrofile.mac in SPEC where the macrofile.mac is a file name (with path if needed).