Skip to content

Commit

Permalink
Allow SFT_TRAINER_CONFIG_JSON_ENV_VAR to be encoded json string (#82)
Browse files Browse the repository at this point in the history
* allow SFT_TRAINER_CONFIG_JSON_ENV_VAR to be encoded json string, not just pickled python

Signed-off-by: Kelly A <[email protected]>

* linting fix

Signed-off-by: Kelly A <[email protected]>

* fix error catching

Signed-off-by: Kelly A <[email protected]>

---------

Signed-off-by: Kelly A <[email protected]>
  • Loading branch information
kellyaa authored Mar 8, 2024
1 parent 9c5a3bf commit 3ac941d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions build/launch_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@
def txt_to_obj(txt):
base64_bytes = txt.encode("ascii")
message_bytes = base64.b64decode(base64_bytes)
obj = pickle.loads(message_bytes)
return obj
try:
# If the bytes represent JSON string
return json.loads(message_bytes)
except UnicodeDecodeError:
# Otherwise the bytes are a pickled python dictionary
return pickle.loads(message_bytes)


def get_highest_checkpoint(dir_path):
Expand Down

0 comments on commit 3ac941d

Please sign in to comment.