Skip to content

fix(train): accept ModelTrainer Tag objects when creating the tuning job - #6438

Open
AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/tuner-tag-objects
Open

AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/tuner-tag-objects

Conversation

@AkshayShah03

Copy link
Copy Markdown

Issue #, if available: N/A

Description of changes:

HyperparameterTuner._prepare_tags_for_tuning merges ModelTrainer.tags into the tuner's tags. Those are typed List[Tag], so they arrive as pydantic Tag objects, while the tuner's own and JumpStart tags are Key/Value dicts. The tuning request then converted every entry with:

tag_objects = [Tag(key=tag["Key"], value=tag["Value"]) for tag in self.tags]

So tuning a ModelTrainer that has tags failed with TypeError: 'Tag' object is not subscriptable.

This change keeps Tag objects as they are and converts dicts, with either Key/Value or key/value.

Testing:

  • New tests/unit/train/test_tuner_tags.py: a ModelTrainer with a Tag plus a tuner dict tag. Both reach HyperParameterTuningJob.create as Tag objects. It fails before this change.
  • Tuner tests: 224 passed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

_prepare_tags_for_tuning merges ModelTrainer.tags (typed List[Tag], so
pydantic Tag objects) into the tuner's tags, which may also hold Key/Value
dicts (tuner tags, JumpStart tags). The tuning request then built tags with
Tag(key=tag['Key'], value=tag['Value']) for every entry, so tuning a
ModelTrainer that has tags failed with
TypeError: 'Tag' object is not subscriptable.

Keep Tag objects as they are and convert dicts (Key/Value or key/value).

This branch is waiting to be deployed

1 waiting deployment
manual-approval — 69929e4f Waiting Oct 12, 2026 by AkshayShah03 via wait-for-approval #622
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.

1 participant