Skip to content

Commit

Permalink
Merge pull request #183 from allenai/attr-merge
Browse files Browse the repository at this point in the history
Preserve existing attributes
  • Loading branch information
rodneykinney committed May 26, 2023
2 parents 47c4ab9 + e0d8fc1 commit 72d4ff2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pretrain_data/mixer/src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ impl Shard {
}

if !attrs.is_empty() {
mutable_data["attributes"] = Value::Object(attrs);
// Add to existing attributes if they exist, otherwise create them.
if let Value::Object(ref mut existing_attrs) = mutable_data["attributes"] {
for (k, v) in attrs.iter() {
existing_attrs.insert(k.clone(), v.clone());
}
} else {
mutable_data["attributes"] = Value::Object(attrs);
}
}

let mut should_write = true;
Expand Down

0 comments on commit 72d4ff2

Please sign in to comment.