AllenNeuralDynamics / aind-watchdog-service

Data staging service that prepares acquistion data for cloud upload to Amazon S3 and Code Ocean processing.
https://allenneuraldynamics.github.io/aind-watchdog-service/
MIT License
2 stars 1 forks source link

Add default yaml dumping method #57

Open bruno-f-cruz opened 2 months ago

bruno-f-cruz commented 2 months ago

We should add a utility method to dump yamls to file so users don't have to worry about figuring out the encoding settings. This should be solved at the same time as #7

bruno-f-cruz commented 2 months ago
 As an example:
   with open(path, "w", encoding="utf-8") as f:
            f.write(_yaml_dump(manifest_config))
        return path

    def _yaml_dump(model: BaseModel) -> str:
        native_json = json.loads(model.model_dump_json())
        return yaml.dump(native_json, default_flow_style=False)