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

Synchronous compilation of a shot #114

Open
dihm opened this issue Jun 13, 2024 · 2 comments · May be fixed by #115
Open

Synchronous compilation of a shot #114

dihm opened this issue Jun 13, 2024 · 2 comments · May be fixed by #115
Labels
question Further information is requested

Comments

@dihm
Copy link
Contributor

dihm commented Jun 13, 2024

I'm currently working with a student on a modification to the installer that will automatically compile the example_apparatus connection table during labscript_profile_create. Goal is to make initial install of labscript less annoying by ensuring BLACS can open with something without requiring manual steps.

Trying things out, it seemed like the synchronous compile functions in runmanager would be perfect (runmanager.compile_labscript and/or runmanager.compile_labscript_with_globals_files). But these functions are not used anywhere in the suite and don't appear to work out of the box.

import labscript
import runmanager
from pathlib import Path

folder = Path("C:\\mydir\\userlib\\labscriptlib\\example_apparatus\\")
script_path = folder.joinpath("connection_table.py")
output_h5_path = folder.joinpath("connection_table.h5")

labscript.labscript_init(output_h5_path, labscript_file=script_path, new=True, load_globals_values=False)
runmanager.compile_labscript(script_path, output_h5_path)
labscript.labscript_cleanup()

Gives the following error

Compilation failed with errors:
Traceback (most recent call last):
  File "C:\Users\naqsL\labscript-suite\userlib\labscriptlib\example_apparatus\connection_table.py", line 27, in <module>
    stop(1.0)
  File "C:\Users\naqsL\src\labscript-suite\labscript\labscript\labscript.py", line 704, in stop
    generate_code()
  File "C:\Users\naqsL\src\labscript-suite\labscript\labscript\labscript.py", line 504, in generate_code
    raise LabscriptError('hdf5 file for compilation not set. Please call labscript_init')
labscript.utils.LabscriptError: hdf5 file for compilation not set. Please call labscript_init

Question is: are we just using these functions incorrectly, or are they actually deprecated and should just be deleted/reworked?

@dihm dihm added the question Further information is requested label Jun 13, 2024
@philipstarkey
Copy link
Member

Yep, those functions look completely broken and should be replaced or removed. The correct way to do it is inside the batch_compiler.py file.

I know you said you want to do it synchronously, but I would consider still using the async functions (that spawn a new process running the batch_compiler.py file) and just waiting for it to complete in the terminal. I'm pretty sure you should be able to redirect the compilation output to the terminal as well? The advantage of doing this is that if it crashes badly, it won't take down the whole command and you can output useful error messages and/or continue on with other things.

@dihm
Copy link
Contributor Author

dihm commented Jun 18, 2024

Makes sense. I'll put together a PR to remove the synchronous functions. I may also add some default options to labscript_compile_* functions so that they just work when compiled naively.

@dihm dihm linked a pull request Jun 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants