Skip to content

Create '--non-interactive' option for setup_openfold#264

Merged
jnwei merged 3 commits into
mainfrom
feature/default-setup-openfold
Jun 17, 2026
Merged

Create '--non-interactive' option for setup_openfold#264
jnwei merged 3 commits into
mainfrom
feature/default-setup-openfold

Conversation

@jnwei

@jnwei jnwei commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary
setup_openfold is currently an interactive script that asks 4 questions regarding where to download the model parameters, which model parameter(s) to download, and whether to run integration tests.

For automated workflows, it is convenient to provide a "--non-interactive" option for the script such that all default options are automatically selected. One immediate use case is in TestSetupOpenfold (in test_entry_points.py), where we need to provide fake values for setup_openfold.main(). Another use case is in example colabfold notebooks, such as #255

Changes

  • Refactor setup_openfold to use a OpenFoldSetupConfig pydantic model to record options, and store default settings. Interactive mode now populates OpenFoldSetupConfig with user input through the same set of queries provided previously.
  • Updates setup_openfold to include --non-interactive option, which will use the default settings of OpenFoldSetupConfig
  • Updates test_entry_points.TestSetupOpenFold with additional test to test default settings and incorporate cli_runner.
  • update documentation

Related Issues
#255

Testing

  • test_entry_points.py tests pass
  • test_inference_full.py passes
  • Manually run setup_openfold on existing .openfold3 cache and new cache directory

@jnwei jnwei requested a review from jandom June 17, 2026 09:14
@jnwei jnwei added the safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing. label Jun 17, 2026
Comment thread openfold3/tests/test_entry_points.py Outdated
Comment on lines +740 to +741
monkeypatch.delenv("OPENFOLD_CACHE", raising=False)
monkeypatch.setenv("HOME", str(tmp_path))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I generally don't try to mix different testing apis/styles, so either monkey patch or patch but not both

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

replaced with patch

Comment thread openfold3/setup_openfold.py Outdated
"""Main execution."""
@click.command()
@click.option(
"--run-with-defaults",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

a more typical flag would be '--quiet' or '--non-interactive'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

replaced with --non-interactive

Comment thread openfold3/setup_openfold.py Outdated
Comment on lines +237 to +274
openfold_cache, ckpt_root_file = setup_openfold_cache()
openfold_cache, ckpt_root_file = setup_openfold_cache(
run_with_defaults=run_with_defaults
)

# Step 2: Set up checkpoint directory
param_dir, should_download = setup_param_directory(openfold_cache, ckpt_root_file)
param_dir, should_download = setup_param_directory(
openfold_cache, ckpt_root_file, run_with_defaults=run_with_defaults
)

# Step 3: Perform download if needed
if should_download:
download_parameters(param_dir)
download_parameters(param_dir, run_with_defaults=run_with_defaults)

# Step 4: Setup CCD with biotite
setup_biotite_ccd(ccd_path=biotite.setup_ccd.OUTPUT_CCD, force_download=False)

# Step 5: Run tests (always run regardless of download status)
run_integration_tests()
run_integration_tests(run_with_defaults=run_with_defaults)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is perhaps the most structural comment (and serious) rather than replicating the boolean flag (these tend to multiply) we pull this out and create a config object, if it's interactive, it asks user how to configure, otherwise it constructs a default one, and we just pass the config object down?

Will break if we need to do a lot of checking if things exist/don't exist when constructing the config

@jnwei jnwei Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PTAL, based on this comment, I made a heavier refactor of setup_openfold. I think it will be worth it / make the options more clear.

@jnwei jnwei requested a review from jandom June 17, 2026 10:36

@jandom jandom left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Excellent imo

)
with env_patch, s3_patch:
os.environ.pop("OPENFOLD_CACHE", None)
result = CliRunner().invoke(setup_openfold.main, ["--non-interactive"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome

Comment on lines +277 to +283
"""Set up OpenFold3 model parameters."""
if config_path is not None:
config = OpenFoldSetupConfig.model_validate_json(config_path.read_text())
elif non_interactive:
config = OpenFoldSetupConfig()
else:
config = _prompt_for_config()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is really nice

@jnwei jnwei changed the title Create 'run-with-defaults' option for setup_openfold Create '--non-interactive' option for setup_openfold Jun 17, 2026
@jnwei jnwei added safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing. and removed safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing. labels Jun 17, 2026
@jnwei jnwei added safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing. and removed safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing. labels Jun 17, 2026
@jnwei jnwei merged commit 6d59795 into main Jun 17, 2026
13 checks passed
@jnwei jnwei deleted the feature/default-setup-openfold branch June 17, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Internal only label used to indicate PRs that are ready for automated CI testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants