-
Notifications
You must be signed in to change notification settings - Fork 17
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
A way to check if code is running in NBInclude #21
Comments
I guess we could add an ret = try
_in_nbinclude[] = true
my_include_string(m, s, string(path, ":In[", cellnum, "]"), prev, softscope)
finally
_in_nbinclude[] = false
end Do you want to take a crack at a PR? |
That looks good, thanks! I'm happy to make a PR (no time right now but in a few days). |
Thinking about it a bit more, it should probably use task-local storage rather than a single global variable. |
In particular, define: const _in_nbinclude = :in_nbinclude_0db19996_df87_5ea3_a455_e3a50d440464 # unique symbol based on our UUID4
in_nbinclude() = get(Base.task_local_storage(), _in_nbinclude, false)::Bool and then do ret = Base.task_local_storage(_in_nbinclude, true) do
my_include_string(m, s, string(path, ":In[", cellnum, "]"), prev, softscope)
end |
Thanks! (sorry for the silence, it's a busy time...) |
It would be nice to have a function available in notebooks to check if code is being run by NBInclude. I currently do something like this:
This is related to #20. However using cell exclusions like in #20 requires setting
regex
in every@nbinclude
call.The text was updated successfully, but these errors were encountered: