Stop hardcoding credentials in ML pipelines - use environment variables instead

Published: 13 December 2022
on channel: Gus Cavanaugh
1,782
25

I always knew hard coding credentials in my code was a terrible idea, but I was lazy and did it anyway.

In addition to being a great way to inadvertently check sensitive information into a public git repository, it also makes deploying your code much harder. Someone has to edit my janky code to provide credentials for staging and prod environments that I don't have access to.

There are lots of ways to handle credentials - many tools have their own secrets management layer - but a simple way to get started is to use environment variables.

They are simple to setup, easy to access from Python, and lots of other tools (like the CI system you should be using) know how to read them:

In this video I show:
bad example -- hardcoded database credentials
better example -- environment variables

At Continual, we're helping ML teams apply good software engineering practices. They don't all manage credentials with environment variables, but none of them hardcode credentials like I used to do. You don't have to use env variables either, but please don't write your credentials in source code. Stay safe out there, and please test & deploy your code.


Watch video Stop hardcoding credentials in ML pipelines - use environment variables instead online without registration, duration hours minute second in high quality. This video was added by user Gus Cavanaugh 13 December 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,782 once and liked it 25 people.