Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic docs for launcher #1044

Closed
wants to merge 13 commits into from
Closed

Conversation

merveenoyan
Copy link
Contributor

This PR includes a github action to have the text-generation-launcher --help output in the documentation.

@merveenoyan
Copy link
Contributor Author

Tested on my local, will update credentials to run this here.

@Narsil
Copy link
Collaborator

Narsil commented Sep 21, 2023

Neat ! Super simple and efficient, I like it !

Don't know about our docs, but if we could include that in a code block would that make it more readable (I don't think the current output is valid markdown)

Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting! 🥳

.github/workflows/auto_docs.yml Outdated Show resolved Hide resolved

git add launcher.md
git commit -m "Update launcher.md"
git push
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be doing a new push to main, but the workflow triggers with every new push. Wouldn't this trigger an infinite loop? (not sure)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I think it would be better to make this check that launcher.md is up to date (as we do with black or isort, they just check but don't change files), and fail if running text-generation-launcher --help >> launcher.md would change the contents of launcher.md, hence forcing users to run this command locally.
(no strong opinion, I think @Narsil had suggested the approach of pushing post-merge)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I setup what you said of having a check instead of force-push, and it also works. Both are fine, but indeed it could trigger infinite loop I don't knwo how GH handles those.

Copy link
Contributor Author

@merveenoyan merveenoyan Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this always be up to date since it runs every time there's a change in main.rs?

rm ../../docs/source/basic_tutorials/launcher.md
echo '```' >> ../../docs/source/basic_tutorials/launcher.md
echo $output >> ../../docs/source/basic_tutorials/launcher.md
echo '```' >> ../../docs/source/basic_tutorials/launcher.md

so whenever there's a change in the file it will always remove the launcher.md and then create new one and post output. Is this what you mean?

Copy link
Contributor Author

@merveenoyan merveenoyan Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed git pushes and it will only update after merger to main (I think below is only way to do so? see https://github.com/orgs/community/discussions/26724#discussioncomment-3253093)

on:
  push:
    paths:
      - "../../launcher/src/main.rs"
    push:
      branches:
        - main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will think more on this, I can't push this way either :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion was to, rather than GA updating launcher.md directly, just have GA check if the changes in main.rs would trigger a change in launcher.md. E.g. you can do this by checking if output == content in launcher.md. If it's the same, nothing happens. If it's different, then the GA workflow fails.

This means that users, not GA, will be forced to run the command to update the doc (it could be a bash script encapsulating everything as well). (again, no strong opinion, it has its pros and cons)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it like so: (also started working in another PR since in this fork the action is not triggered)

  - name: Update Docs
     run: |
       output="${{ steps.run-launcher-help.outputs.output }}"
       launcher_content=$(/docs/source/basic_tutorials/launcher.md)

       if [ "$launcher_content" != "$output" ]; then
         rm /docs/source/basic_tutorials/launcher.md
         echo '```' >> /docs/source/basic_tutorials/launcher.md
         echo $output >> /docs/source/basic_tutorials/launcher.md
         echo '```' >> /docs/source/basic_tutorials/launcher.md
         echo "Docs are updated!"

         git add launcher.md
         git commit -m "Update launcher.md"
         git push

- name: Run TGI Launcher docs
id: run-launcher-help
run: |
output=$(text-generation-launcher --help)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the GitHub Actions workflow has anything installed to run text-generation-launcher --help. You will need to either install this in GH Actions or use a Docker GA that allows you to do docker run ghcr.io/huggingface/text-generation-inference:latest --help (which I think has same output)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include it in the build step too (because there it's available as the docker image)

Copy link
Contributor Author

@merveenoyan merveenoyan Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osanseviero @Narsil I feel like installing from docker doesn't make sense given text-generation-launcher --help will not check main.rs in that branch, does it? So is the output going to come from the source? I tested it and it was coming from docker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized make install works better for this case.

@merveenoyan
Copy link
Contributor Author

@Narsil just edited to add codeblock.

@Narsil
Copy link
Collaborator

Narsil commented Sep 21, 2023

@Narsil just edited to add codeblock.

By the way to test gh action, what I usually do is remove the filter so that it runs on the current PR

@merveenoyan
Copy link
Contributor Author

Apparently if we do:

on:
  pull_request:
    types:
      - closed

jobs:
  update_docs:
    if: github.event.pull_request.merged == true

it should work. I will not add this now to test the action on this branch though:

  pull_request:
    types:
      - closed
```

@merveenoyan
Copy link
Contributor Author

continuing from this PR since GHA is not recognized in my fork (not even skipped) #1045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants