Julien Beaulieu
12/11/2024, 6:45 PMupload_blob , download_blob , and hide the implementation of either GCP or AWS. Maybe gcp or aws could be passed as an input to those functions, and I'd build the logic with Hamilton to load the proper module. Same for our data warehouse and deployment functions.
In the screenshot below, you can see an example of some gcloud storage functions I quickly put together.
Questions
1. If I am just building functions for just GCP, what might be some advantages of using Hamilton vs coding this in "plain Python" and just using the gcloud library? Seems like the latter would be simpler.
a. I understand the observability features I'd get with Hamilton, but saving to GCS isn't a complex data transformation like you could find with feature engineering for ex.
b. Would it make sense to use Hamilton at all for this use case? It would make sense to me if I were implementing end to end data transformations with the last step being "save to GCS". But in my use case, I'm only implementing "saving/loading to GCS" without the middle transformations. Whatever transformations come before or after wouldn't be using Hamilton (...yet) since other people in the team would be writing them and wouldn't be onboarded with Hamilton yet. Maybe Hamilton would be "overkill" for this?
2. Assuming Hamilton is a great choice for my use case, and that I'm moving forward with a 2 layer api approach, I'm wondering what features you would suggest for implementation?
a. Should I opt for a basic module -> driver -> execute approach for each function I may want to provide to start? Would I be missing out on some of the more advanced features like materilizers, DataLoaders/DataSavers, config, etc? Any pattern you would recommend for me?
b. Do you have examples of anything resembling my use case? For this 2 layer API approach, I was looking at this data_loaders example where 3 different implementations are done and the driver then calls either one of the modules to get executed.
I have lots of other projects going on that might be a better fit for a good demo perhaps: ex - Airflow DAG where I am running batch model predictions that are saved to a table. Let me know if I should save my Hamilton efforts for that, or if I should start using it now.
I appreciate your help and let me know if you need more information
Thanks for all your work!Stefan Krawczyk
12/11/2024, 7:05 PM1. If I am just building functions for just GCP, what might be some advantages of using Hamilton vs coding this in āplain Pythonā and just using thelibrary? Seems like the latter would be simpler.gcloud
a. I understand the observability features Iād get with Hamilton, but saving to GCS isnāt a complex data transformation like you could find with feature engineering for ex.
b. Would it make sense to use Hamilton at all for this use case? It would make sense to me if I were implementing end to end data transformations with the last step being āsave to GCSā. But in my use case, Iām only implementing āsaving/loading to GCSā without the middle transformations. Whatever transformations come before or after wouldnāt be using Hamilton (...yet) since other people in the team would be writing them and wouldnāt be onboarded with Hamilton yet. Maybe Hamilton would be āoverkillā for this?You can use Hamilton here, but yes it might be overkill. The upside of using Hamilton is that if you wanted to add logging, get that nice picture, etc. you can use the framework, or if you wanted to feature flag different implementations you can do so.
Stefan Krawczyk
12/11/2024, 7:10 PM1. Assuming Hamilton is a great choice for my use case, and that Iām moving forward with a 2 layer api approach, Iām wondering what features you would suggest for implementation?
a. Should I opt for a basic module -> driver -> execute approach for each function I may want to provide to start? Would I be missing out on some of the more advanced features like materilizers, DataLoaders/DataSavers, config, etc? Any pattern you would recommend for me?
b. Do you have examples of anything resembling my use case? For this 2 layer API approach, I was looking at this data_loaders example where 3 different implementations are done and the driver then calls either one of the modules to get executed.The two-layer approach should allow you to change things later without much hassle so it lowers your risk here. Materializers are basically just a way to centralize some logic and/or inject nodes into the hamilton DAG. So start without them, and once you see repeated code, etc. then reach for them⦠IIUC the two layer API with hamilton would be:
# higher level API
def upload_gcs_blob(something) -> dict:
# lower level API
dr = driver.Builder().with_config({...}).with_modules(gcs_hamilton).build()
result = dr.execute(["upload_blob"], inputs={...})
# massage result to conform to API
return resultStefan Krawczyk
12/11/2024, 7:12 PMI have lots of other projects going on that might be a better fit for a good demo perhaps: ex - Airflow DAG where I am running batch model predictions that are saved to a table. Let me know if I should save my Hamilton efforts for that, or if I should start using it now.No strong answer here. But definitely a fit for airflow (@Thierry Jean has a blog on that).
Stefan Krawczyk
12/11/2024, 7:17 PMJulien Beaulieu
12/11/2024, 9:11 PM