Skip to content

MAINT: Align fmu init with fmu-settings init behavior#109

Merged
GibranAlfa merged 2 commits intoequinor:mainfrom
GibranAlfa:align-fmu-init
Mar 27, 2026
Merged

MAINT: Align fmu init with fmu-settings init behavior#109
GibranAlfa merged 2 commits intoequinor:mainfrom
GibranAlfa:align-fmu-init

Conversation

@GibranAlfa
Copy link
Copy Markdown
Collaborator

@GibranAlfa GibranAlfa commented Mar 27, 2026

Resolves #106

Aligned fmu init with fmu-settings init behavior

Checklist

  • Tests added (if not, comment why)
  • Test coverage equal or up from main (run pytest with --cov=src/ --cov-report term-missing)
  • If not squash merging, every commit passes tests
  • Appropriate commit prefix and precise commit message used
  • All debug prints and unnecessary comments removed
  • Docstrings are correct and updated
  • Documentation is updated, if necessary
  • Latest main rebased/merged into branch
  • Added comments on this PR where appropriate to help reviewers
  • Moved issue status on project board
  • Checked the boxes in this checklist ✅

target_fmu_dir = get_fmu_directory(self.target)
except FileNotFoundError:
target_fmu_dir = init_fmu_directory(self.target)
target_fmu_dir = init_fmu_directory(self.target, force=True)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

skip project-root validation here because copy targets are not necessarily FMU project roots. we still create a target .fmu so we can log the copy in its changelog.

show_default=False,
),
] = False,
skip_config_import: Annotated[
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

--skip-config-import option is removed to align the behavior to fmu-settings init behavior that auto import global config. i don't see any use case where the user need to skip config import, if there is a use case for that, then fmu-settings init has to be updated to support skip config import

error(
"Unable to create .fmu directory.",
reason=str(e),
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no suggestion added here because the error message is already clear:

"Failed initializing .fmu directory. Initialize it from a project "
 f"root containing {required_dirs}. Did not find: "
 f"{missing_dirs_text}."

assert "Success: All done!" in stdout
assert "Info: Project stratigraphy was not imported by 'fmu init'." in stdout
assert "Open 'fmu settings' to import stratigraphy from RMS" in stdout
assert _find_global_config_source(tmp_path) == (
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

assert the discovered config source directly instead of relying on the rendered CLI output, which can wrap long absolute paths and make the string assertion flaky.

assert "Success: All done!" in stdout


def test_init_skips_adding_global_variables_with_masterdata(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed test with skip config import option

assert "Success: All done!" in result.stdout


def test_init_skips_raising_when_import_drogon_masterdata_with_skip(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

same as above

@GibranAlfa GibranAlfa requested review from mferrera and slangeveld and removed request for mferrera March 27, 2026 11:25
@GibranAlfa GibranAlfa merged commit 082d3f6 into equinor:main Mar 27, 2026
7 checks passed
@GibranAlfa GibranAlfa deleted the align-fmu-init branch March 27, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync the fmu init functionality with init from fmu-settings

2 participants