Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/pip/qsharp/_qsharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,16 @@ def compile(entry_expr: Union[str, Callable], *args) -> QirInputData:
ipython_helper()
start = monotonic()
global _config
interpreter = get_interpreter()
Copy link
Member

Choose a reason for hiding this comment

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

I think this is the online line (besides init and get_interpreter() itself) that tries to access this global directy like this... which feels like a risky pattern I'd rather not perpetuate. I wonder if instead get_interpreter() should return the config, and we always access it through that call to ensure it's initialized?

target_profile = _config._config.get("targetProfile", "unspecified")
telemetry_events.on_compile(target_profile)
if isinstance(entry_expr, Callable) and hasattr(entry_expr, "__global_callable"):
args = python_args_to_interpreter_args(args)
ll_str = get_interpreter().qir(
ll_str = interpreter.qir(
entry_expr=None, callable=entry_expr.__global_callable, args=args
)
else:
ll_str = get_interpreter().qir(entry_expr=entry_expr)
ll_str = interpreter.qir(entry_expr=entry_expr)
res = QirInputData("main", ll_str)
durationMs = (monotonic() - start) * 1000
telemetry_events.on_compile_end(durationMs, target_profile)
Expand Down
Loading