SimulationProject.get_name() prefers the declared name over the directory basename#4
Open
tabgab wants to merge 1 commit intoomnetpp:mainfrom
Open
SimulationProject.get_name() prefers the declared name over the directory basename#4tabgab wants to merge 1 commit intoomnetpp:mainfrom
tabgab wants to merge 1 commit intoomnetpp:mainfrom
Conversation
…tory basename
When a SimulationProject is loaded from a '.opp' file that explicitly
sets name="mm1k" but the file sits in a directory called 'mm1k-verify',
get_name() currently returns 'mm1k-verify' — the directory basename —
because it only uses os.path.basename(self.get_full_path(".")).
This makes log / error lines confusing:
Exception: Building mm1k-verify failed # the project IS named mm1k
With this change, get_name() returns self.name when set, falling back
to the directory basename only when no explicit name was provided
(e.g. for an OmnetppProject defined purely by root_folder).
Reproducer (on any version of main prior to this fix):
# In a dir /tmp/foo:
cat > myproj.opp <<'OPP'
SimulationProject(
name="myproj",
root_folder=".",
build_types=["executable"],
executables=["myproj"],
ned_folders=["."],
ini_file_folders=["."],
)
OPP
# From Python:
>>> load_opp_file("./myproj.opp")
>>> p = get_simulation_project("myproj")
>>> p.name
'myproj'
>>> p.get_name()
'foo' # <-- should be 'myproj'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SimulationProject.get_name()currently returns the directory basename,not the project's declared
name=attribute. When the.oppfile sits ina directory whose name differs from
name=, every log and error linereferring to the project uses the wrong identifier.
Real-world symptom (from an agent walking through
testprompt.txtin anew skill pack I built for opp_repl):
because
/tmp/mm1k-verify/mm1k.oppdeclaresname="mm1k"but thedirectory is
mm1k-verify.Change
Two lines in
opp_repl/simulation/project.py:Falls back to the directory basename only when no explicit name was
provided (e.g. an
OmnetppProjectdefined purely byroot_folder),preserving existing behaviour for that case.
Reproducer
Context
I maintain tabgab/opp_repl-skill,
a pack of Anthropic-format Agent Skills for driving opp_repl from AI
agents. While verifying the skills end-to-end I hit this issue and
wrote it up. Happy to iterate on the fix if you prefer a different
fallback policy.