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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow cell magic body to be a $variable #1053

Merged
merged 8 commits into from Nov 16, 2021
Merged

Conversation

@plamut
Copy link
Contributor

@plamut plamut commented Nov 8, 2021

Closes #1040.

Thought - we probably want to follow up with a sample demonstrating this new use case.

Also, the length of the _cell_magic() function should be ignored for now, it's been waiting to be split into smaller units since forever. 馃檪

PR checklist:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
@plamut plamut requested a review from loferris Nov 8, 2021
@plamut plamut requested review from as code owners Nov 8, 2021
@google-cla google-cla bot added the cla: yes label Nov 8, 2021
google/cloud/bigquery/magics/magics.py Outdated Show resolved Hide resolved
google/cloud/bigquery/magics/magics.py Outdated Show resolved Hide resolved
@google-cla
Copy link

@google-cla google-cla bot commented Nov 8, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

鈩癸笍 Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Nov 8, 2021
@tseaver
Copy link
Contributor

@tseaver tseaver commented Nov 8, 2021

@googlebot I consent.

@google-cla
Copy link

@google-cla google-cla bot commented Nov 8, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

鈩癸笍 Googlers: Go here for more info.

@tseaver
Copy link
Contributor

@tseaver tseaver commented Nov 8, 2021

@plamut Sorry, I tried. :-<

@plamut
Copy link
Contributor Author

@plamut plamut commented Nov 8, 2021

OK, I'll edit the commit message then to silence the bot.

tseaver
tseaver approved these changes Nov 9, 2021
cell_body = "$custom_query"

with pytest.raises(
NameError, match=r".*custom_query does not exist.*"
Copy link
Contributor

@loferris loferris Nov 10, 2021

Choose a reason for hiding this comment

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

Maybe comment to indicate we're testing the first kind of error, as I got the regex string match from context of the other file.

Copy link
Contributor Author

@plamut plamut Nov 10, 2021

Choose a reason for hiding this comment

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

The name of the test explains which case it covers ("non-existing query variable"), do you think that's not sufficient by itself?

I always look at the name of the test first, although it might be just how my brain is wired...

Update: Added a comment next to the assignment to cell_body to explain which use case it targets.

Copy link
Contributor

@loferris loferris Nov 16, 2021

Choose a reason for hiding this comment

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

LGTM - I really like how you added the "non-existing query variable" condition.

Copy link
Contributor

@loferris loferris left a comment

LGTM - could do with more comments on test cases, perhaps.

cell_body = "$custom_query"

with pytest.raises(
TypeError, match=r".*must be a string or a bytes-like.*"
Copy link
Contributor

@loferris loferris Nov 10, 2021

Choose a reason for hiding this comment

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

Might be good to have another comment here to match it to the other else condition in run_query_magic

tests/unit/test_magics.py Outdated Show resolved Hide resolved
@plamut plamut removed the automerge label Nov 11, 2021
@plamut plamut requested a review from loferris Nov 11, 2021
@loferris
Copy link
Contributor

@loferris loferris commented Nov 16, 2021

LGTM - appreciate the changes!!

@plamut plamut merged commit 3a681e0 into googleapis:main Nov 16, 2021
16 checks passed
@plamut plamut deleted the iss-1040 branch Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants