-
Notifications
You must be signed in to change notification settings - Fork 75
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
Actually use auto generate examples script #686
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. just a few nits but looks great overall.
bin/generate_truss_examples.py
Outdated
@@ -0,0 +1,301 @@ | |||
""" | |||
Script to take the Truss examples in https://github.com/basetenlabs/truss-examples-2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use truss-examples
now that it has the new structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, yeah it is truss-examples now, just need to fix this comment
bin/generate_truss_examples.py
Outdated
If the destination directory exists, remove it. | ||
Then, clone the given repo into the specified directory. | ||
""" | ||
if os.path.exists(DESTINATION_DIR): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prefer to use pathlib.Path
operations over os.path
to stay consistent with the style of the rest of the repo
bin/generate_truss_examples.py
Outdated
|
||
|
||
def _get_file_type(file_path: str) -> FileType: | ||
_, extension = os.path.splitext(file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripped_line = line.strip() | ||
|
||
# Case of Markdown line | ||
if stripped_line.startswith("#"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to handle multiple comments/docstrings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this -- parsing out docstrings is a little tough. Since for the examples that we are including in the docs we are in charge of, I thin it's easier if we just choose to use the "#" style comments to write the "doc" part of this
See Loom: https://www.loom.com/share/3777c502e5104ab4a60d701c927b2a64
Branches off of #676. This PR actually generates the automatic examples, and adds them to the repo. Note that for now, we check in all of the auto-generated examples.
Please take a look at this PR, and make whatever changes you want in the https://github.com/basetenlabs/truss-examples-2 repo.
How to auto-generate examples
In Truss: