Is gui directive still valid?

Hi,

I see that the #|gui directive is not listed here Directives – nbdev. Is it still valid?

If I use it in a cell the cell runs when I execute the notebook in vscode and it does not run when I execute nbdev_prepare from the DOS prompt. This is what I expect.

However, the cell does run during CI when committed to github, which I would not expect. Is this correct. If so, is there a directive to ensure a cell is not executed during CI?

Hello,

#|gui Directive:

Validity: The #|gui directive is not explicitly mentioned in the official nbdev documentation. This might indicate it’s an undocumented or less commonly used feature.

Behavior:

Local Execution (VS Code): Cells with #|gui run when executing the notebook within VS Code.
nbdev_prepare: Cells with #|gui are not executed when running nbdev_prepare from the command line. This is the expected behavior.
CI (GitHub Actions): You’re observing unexpected behavior where cells with #|gui do run during CI. This could be due to how your CI workflow is configured.
Preventing Cell Execution During CI:

While #|gui might not directly prevent execution in CI, here are some strategies to ensure cells are not run during your CI process:

Conditional Execution:

Use if name == “main”:: Wrap the cell’s code within this conditional block. This ensures the code only runs when the script is executed directly (like in VS Code) and not when imported as a module (which happens during CI).
Python

if name == “main”:
# Your GUI-related code here
Environment Variables:

Check for CI environment: Most CI systems (like GitHub Actions) provide environment variables that indicate the CI environment (e.g., CI=true, GITHUB_ACTIONS=true). Check for these variables and skip execution if they are set.
Python

if “CI” not in os.environ:
# Your GUI-related code here
nbdev Configuration:

Explore nbdev configuration: Investigate if there are any configuration options within the _nbdev.yml file that can control cell execution behavior during CI.
Investigating CI Workflow:

Examine CI configuration: Carefully review your GitHub Actions workflow file (or equivalent for your CI system). Look for any steps or commands that might be triggering the execution of notebooks or cells.
Debugging: Add print statements or logging within your cells to understand the execution flow during CI.
By implementing these strategies, you can effectively prevent cells with #|gui or other specific cells from running during your CI process, ensuring a cleaner and more predictable build.

Disclaimer:

The #|gui directive’s behavior and its interaction with CI might vary depending on your specific nbdev setup and CI configuration. obamacare login

This response provides general guidance. The most accurate and reliable solution will depend on your particular circumstances.

Best Regards