Skip to content
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

Core: Fix Generate's slot parsing to default unknown slot names to file name #3795

Merged
merged 3 commits into from
Sep 8, 2024

Conversation

qwint
Copy link
Contributor

@qwint qwint commented Aug 14, 2024

What is this fixing or adding?

make Generate handle slots without names defined better; fix existing code that seemed to want to handle missing names but was no longer functioning correctly

if there is a better solution than what the existing code was trying to do then i differ to that

How was this tested?

https://discord.com/channels/731205301247803413/1273345114198118502
tested with the original provided yaml and with a copy that moved the slot without a name to the bottom of the yaml and confirmed with pdb that the args.name got created properly and defaulted to file name when name was missing
also tested with two slots missing name in the same yaml and saw it throw an error mentioning the duplicate names, not sure if that's the best error handling but it works enough for me

If this makes graphical changes, please attach screenshots.

@github-actions github-actions bot added affects: core Issues/PRs that touch core and may need additional validation. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels Aug 14, 2024
@Exempt-Medic Exempt-Medic added the is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. label Aug 14, 2024
if path == args.weights_file_path: # if name came from the weights file, just use base player name
erargs.name[player] = f"Player{player}"
elif not erargs.name[player]: # if name was not specified, generate it from filename
elif player not in erargs.name: # if name was not specified, generate it from filename
erargs.name[player] = os.path.splitext(os.path.split(path)[-1])[0]
erargs.name[player] = handle_name(erargs.name[player], player, name_counter)
Copy link
Member

Choose a reason for hiding this comment

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

Unsure if you'd want to add this to this PR, but this does technically change the fact that previously you could name yourself false (which would get changed to the yaml name) and now you cannot name yourself anything boolean in yaml. Could add this to fix it, but maybe there's a better way?

Suggested change
erargs.name[player] = handle_name(erargs.name[player], player, name_counter)
erargs.name[player] = handle_name(str(erargs.name[player]), player, name_counter)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is expected / what currently works? if you name yourself "false" it currently ignores the name and runs through this code to get the filename instead?

Copy link
Member

Choose a reason for hiding this comment

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

If you name yourself false (no quotation marks) currently it ends up actually hitting the yaml name rename line because your name evaluates as, well, False. This is clearly unintended, but the name does work just fine on WebHost, so I guess it converts to a string somewhere. I think it would make sense to do the same here so that name: false, name: on etc. will gen instead of crashing

Copy link
Member

@Exempt-Medic Exempt-Medic left a comment

Choose a reason for hiding this comment

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

The changes LGTM. Tested them with various configurations of yamls, weights, names/namelessness, and errors were improved and the renaming now works. One small comment on something that's probably out of scope.

Copy link
Member

@NewSoupVi NewSoupVi left a comment

Choose a reason for hiding this comment

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

Seems reasonable, I had a comment

Generate.py Outdated Show resolved Hide resolved
@NewSoupVi NewSoupVi merged commit cf375cb into ArchipelagoMW:main Sep 8, 2024
18 checks passed
@qwint qwint deleted the gen_slot_names branch September 8, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants