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

Add 'final' and 'strip' to hooks, rework 'ensure_lab' and github on demand #11

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

athornton
Copy link
Member

No description provided.

@athornton athornton force-pushed the tickets/DM-46954 branch 3 times, most recently from 6826bde to 6bb795d Compare October 21, 2024 23:28
@athornton athornton changed the title Add 'final' to hooks, rework 'ensure_lab' Add 'final' and 'strip' to hooks, rework 'ensure_lab' Oct 21, 2024
@athornton athornton changed the title Add 'final' and 'strip' to hooks, rework 'ensure_lab' Add 'final' and 'strip' to hooks, rework 'ensure_lab' and github on demand Oct 21, 2024
@athornton athornton requested a review from stvoutsin October 21, 2024 23:54
Copy link
Member

@stvoutsin stvoutsin left a comment

Choose a reason for hiding this comment

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

Looks good to me.
I've tested this out on dev and it all worked fine, with & without branches in the paths.
The suggestions here are just personal preference / nitpicky so up to you if you want to change anything based on them.

@@ -21,7 +21,7 @@ To signal failure, a hook should raise an ``Exception``.
If a hook does not wish to modify the parameters used by future hooks or
Copy link
Member

Choose a reason for hiding this comment

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

There's a typo (not in your recent changes) just above:
modififactions -> modifications

src/ghostwriter/services/rewrite.py Show resolved Hide resolved
src/ghostwriter/hooks/github_notebook.py Outdated Show resolved Hide resolved
src/ghostwriter/hooks/github_notebook.py Show resolved Hide resolved
src/ghostwriter/hooks/github_notebook.py Outdated Show resolved Hide resolved
src/ghostwriter/hooks/github_notebook.py Show resolved Hide resolved
src/ghostwriter/hooks/autostart_lab.py Show resolved Hide resolved


async def github_notebook(params: Parameters) -> Parameters | None:
async def github_notebook(params: Parameters) -> Parameters:
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a suggestion for when you have more development effort on this would be splitting the path processing here to its own method and writing some tests for that to make sure it can handle all unusual cases of paths

Comment on lines +48 to +54
prefix = "notebooks/github.com/"
if path.startswith(prefix):
# Needs stripping
path = path[(len(prefix)) :]
if path.endswith(".ipynb"):
# Also needs stripping
path = path[: -(len(".ipynb"))]
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this would be simpler:

path = path.removeprefix("notebooks/github.com/").removesuffix(".ipynb")

@athornton athornton merged commit 8b199a7 into main Oct 22, 2024
5 checks passed
@athornton athornton deleted the tickets/DM-46954 branch October 22, 2024 20:46
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