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

docs(samples): add samples for IN, NOT_IN, and != operators. #312

Merged
merged 19 commits into from Jun 16, 2022

Conversation

jlara310
Copy link
Contributor

@jlara310 jlara310 commented May 24, 2022

docs: add samples for IN, NOT_IN, and != operators.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • 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)

Fixes #311 🦕

@jlara310 jlara310 requested review from a team as code owners May 24, 2022 21:05
@jlara310 jlara310 requested a review from engelke May 24, 2022 21:05
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label May 24, 2022
@snippet-bot
Copy link

snippet-bot bot commented May 24, 2022

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: datastore Issues related to the googleapis/python-datastore API. samples Issues that are directly related to samples. labels May 24, 2022
@jlara310
Copy link
Contributor Author

Depends on #287

@jlara310 jlara310 changed the title Add samples for IN, NOT_IN, and != operators. docs: Add samples for IN, NOT_IN, and != operators. May 25, 2022
@jlara310 jlara310 changed the title docs: Add samples for IN, NOT_IN, and != operators. docs: add samples for IN, NOT_IN, and != operators. May 25, 2022
samples/snippets_test.py Outdated Show resolved Hide resolved
@Mariatta Mariatta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 9, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 9, 2022
@Mariatta Mariatta added the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 9, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 9, 2022
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jun 9, 2022
@jlara310
Copy link
Contributor Author

Now that #287 merged, this is ready for review/merge, too.

@jlara310
Copy link
Contributor Author

The project used for testing requires the indexes in samples/index.yaml. Can someone help me add that index to the testing project?

gcloud datastore create index.yaml

@jlara310 jlara310 requested a review from Mariatta June 10, 2022 07:18
@yoshi-kokoro yoshi-kokoro removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jun 10, 2022
@Mariatta
Copy link
Contributor

Ok looks like the samples tests are now running, and there are some errors.

@jlara310 jlara310 requested a review from Mariatta June 13, 2022 18:44
@jlara310
Copy link
Contributor Author

I saw errors like this one for the unit tests:

details = "Datastore-Native databases do not support IN filters. Upgrade to Datastore-Mode to enable this."

Looks like the testing project is on the legacy Cloud Datastore backend. The new query features are only available for Firestore in Datastore mode. I'm not sure how to resolve this without creating a new testing project.

@jlara310
Copy link
Contributor Author

jlara310 commented Jun 13, 2022

Looks like it's just python-docs-samples-tests that is on the legacy back-end. The build-specific projects look to be on Firestore in Datastore mode. Opting into those in the noxfile to use them for testing.

The other projects will also require the new index:

python-docs-samples-tests-py36
python-docs-samples-tests-py37
python-docs-samples-tests-py38
python-docs-samples-tests-py39
python-docs-samples-tests-310

indexes:

  • kind: Task
    properties:
    • name: tag
    • name: tag

@jlara310
Copy link
Contributor Author

Added a test fixture to set up the required index if it doesn't already exist. However, I'm now getting this error when attempting to create that index:

"google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission"

Either I didn't set things up quite right or the service account doesn't have index creation permissions on the build-specific test projects.

@jlara310
Copy link
Contributor Author

jlara310 commented Jun 15, 2022

I removed the snippets that require an index for now. I'd like to submit the remaining snippets as that will allow me to update the documentation. I can figure out the other two snippets in a follow-up PR.

I'm still failing two checks, but I'm not sure why. Any insights appreciated.

Kokoro — Build failed error:

nox > * docs: failed

Kokoro Prerelease Dependencies error:

ERROR collecting samples/snippets/snippets_test.py
Traceback:
/usr/local/lib/python3.8/importlib/init.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
samples/snippets/snippets_test.py:16: in
import backoff
E ModuleNotFoundError: No module named 'backoff'

@dandhlee dandhlee added the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 15, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 15, 2022
@dandhlee dandhlee added the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 15, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 15, 2022
@jlara310
Copy link
Contributor Author

PR should be good to go and ready to merge. Thank you.

if name in ("main", "_preamble", "defaultdict") or not callable(function):
continue

print(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering what is the purpose of the prints here?

One of the output is for the pprint:

pprint
<google.cloud.datastore.client.Client object at 0x1096a7820>
None

Perhaps we don't need these prints?

@Mariatta Mariatta changed the title docs: add samples for IN, NOT_IN, and != operators. docs(samples): add samples for IN, NOT_IN, and != operators. Jun 16, 2022
@Mariatta
Copy link
Contributor

The pre-release dependencies CI is not needed so it's good to merge. Thank you!

@Mariatta Mariatta merged commit 4170325 into googleapis:main Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-datastore API. samples Issues that are directly related to samples. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Datastore query samples for IN, NOT_IN, NOT_EQUAL
4 participants