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

Actually use auto generate examples script #686

Merged
merged 18 commits into from
Oct 13, 2023

Conversation

squidarth
Copy link
Collaborator

@squidarth squidarth commented Sep 28, 2023

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:

$  poetry run python  ./bin/generate_truss_examples.py
``

Review & commit the changeset that it generates

![truss-examples-screenshot](https://github.com/basetenlabs/truss/assets/850115/28fff59c-9896-412a-8298-8a51e03f4b91)

@squidarth squidarth changed the base branch from main to sshanker/auto-generate-docs-script September 28, 2023 16:16
@squidarth squidarth changed the base branch from sshanker/auto-generate-docs-script to main October 12, 2023 00:03
@squidarth squidarth requested a review from bolasim October 12, 2023 00:03
Copy link
Collaborator

@bolasim bolasim left a 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.

@@ -0,0 +1,301 @@
"""
Script to take the Truss examples in https://github.com/basetenlabs/truss-examples-2,
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

If the destination directory exists, remove it.
Then, clone the given repo into the specified directory.
"""
if os.path.exists(DESTINATION_DIR):
Copy link
Collaborator

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



def _get_file_type(file_path: str) -> FileType:
_, extension = os.path.splitext(file_path)
Copy link
Collaborator

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("#"):
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

@squidarth squidarth merged commit 8d33e9f into main Oct 13, 2023
3 checks passed
@squidarth squidarth deleted the shsanker/use-auto-generate-examples-script branch October 13, 2023 16:12
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.

2 participants