nasaharvest / crop-mask

End-to-end workflow for generating high resolution cropland maps
Apache License 2.0
95 stars 28 forks source link

Send notification when new models are deployed #184

Open ivanzvonkov opened 2 years ago

ivanzvonkov commented 2 years ago

Context: You can only see which models are newly deployed by paying attention to the data/models.json

Issue: For people not paying attention to crop-mask Pull Requests, it's not immediately obvious which models have been recently deployed.

Potential solution: Create a Github action to send a slack message when a new model is uploaded

hannah-rae commented 2 years ago

love this idea!

KanishkKhurana commented 1 year ago

Hi, I really like this idea and i would love to contribute! Please let me know if I can do that, and how to get started.

ivanzvonkov commented 1 year ago

Hi @KanishkKhurana, this is great to hear!

Here's an approach you could try:

  1. Setup a personal Slack workspace (feel free to invite me)
  2. Create a Github Action with slack-send (or similar)
  3. Figure out how to only trigger that Github Action on updates to models.json
  4. Figure out how to extract the newly added model in models.json so it can be included in the slack message.
  5. Once it's fully functioning, add the newly created Github Action as a job inside the deploy Github action (the message should only be sent once deployment has finished)

Once we have everything working we'll update the code to point to NASA Harvest's slack workspace and could invite you there to verify that it works! Let me know if you have any questions.

KanishkKhurana commented 1 year ago

Thank you for laying out the action plan for me! This really helps a lot. I will get started soon and inform you of the developments!

KanishkKhurana commented 1 year ago

Hi @ivanzvonkov , I have made some progress, but I was having issues with deploying the changes. I think it was because of the secrets used in deploy.yml, but I'll need your opinion on it.

Anyway, before opening a PR, here's the file to notify slack users- https://github.com/KanishkKhurana/crop-mask/blob/master/.github/workflows/Model-Slack-Notifier.yml

And here's the link to the demo slack app I have been using- https://join.slack.com/t/demo-crop-mask/shared_invite/zt-19web4y0x-G2KOJDGoMpe_b2QgOBjrJQ

ivanzvonkov commented 1 year ago

@KanishkKhurana yes you are correct about the deploy.yml Github action not running because the secrets are not available in your forked repository. I was going to suggest commenting out the deploy.yml file but I see you are already one step ahead of me 😄. Once the code is ready you can comment the file back in and we'll have to test the full changes inside this repository.

KanishkKhurana commented 1 year ago

Hi @ivanzvonkov , Hahah yes I was experimenting with the deploy.yml. I still have to do a few edits in code, and I will let you know once I have something ready.

KanishkKhurana commented 1 year ago

I have fixed most bugs in the code, but so far I couldnt find any way to see the new model added to the file in the Github event and payload docs. However, if we click on the link of the commit message in slack, we can see the changes. Is there was to fetch these changes in the commit ? Also, if while adding the new model, we copy and paste the model details in the commit message, that can be easily fetched and shown in the slack chat. I wanted to know if this method can be pursued.

KanishkKhurana commented 1 year ago

hi @ivanzvonkov , just pinging you again to hear your views on the questions above. In the meanwhile i am trying to use Get-Diff-Action to fetch file changes and post them to the slack channel

ivanzvonkov commented 1 year ago

Hi @KanishkKhurana apologies for the late response, I have been out of office for some of June.

The Github action can be triggered by a change to data/models.dvc. Similar to: https://github.com/nasaharvest/crop-mask/blob/a610829355e0d257397a9f7fdd4710ff9f64ea60/.github/workflows/deploy.yml#L6

I suggest for the first iteration just posting a slack message of all the models that are available. Then after that Pull Request we can discuss the simplest way to pull a specific model for the message. Pulling a model name from the commit is a bit flaky I think.

KanishkKhurana commented 1 year ago

Hi @ivanzvonkov , I hope you are doing good ! i will update the YAML file to fetch run only when something changes in models.dvc, earlier the trigger was on models.json. What we can do right now is send a link in the slack channel whenever something changes in the models.dvc file. and upon clicking on that link you can see the changes. If this is okay, I can ship this to your slack channel asap. I agree that putting model name in commit message is flaky , but so far I couldn't find a ready service to fetch the "git diff" when a commit is done. Meanwhile, I will scout for some way to get the git-diff. If you have any suggestions on this, it could really me here.

ivanzvonkov commented 1 year ago

This sounds good, feel free to open a PR when everything is ready!

KanishkKhurana commented 1 year ago

Sorry for being a little out of touch lately, was a bit busy with university exams. Please let me know the channel ID in slack of the channel in which you want the updates, or we can add that as a secret as well if you want and I will finish the code and raise the PR.

ivanzvonkov commented 1 year ago

Could you use the temporary slack channel you created for this? It would be great if you could add the channel ID and auth information (if necessary) as secrets in your fork. Then I'll add the secrets in this repo prior to the PR being merged.

KanishkKhurana commented 1 year ago

Testing is complete on the temporary channel. We will have to add a bot to the slack organization and connect it to the github action. channel id can be a secret like you said. I can help with the bot incase you need, and other changes are mostly done.

ivanzvonkov commented 1 year ago

Great, feel free to make a PR from your fork when ready!