Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

docs: add sync api samples with json request #13

Merged
merged 24 commits into from
Apr 6, 2022

Conversation

changsongd
Copy link
Contributor

Previous PR is here: #5

The previous PR was deleted because @dizcology suggested that using the auto-generated code samples can already serve our purpose and can also provide the benefits of easy maintainability. However, after reviewing our product documents, TPM and eng raised the concern that customers may feel confused about the linked code samples. The code sample construct the request in the code. But in reality, customers tend to construct the request in a json file. Thus they may find it hard to parse and use the json file without us showing them how to do it in code. This PR is to add a code snippet for the sync API that reads the request from a json file.

@changsongd changsongd requested a review from a team as a code owner April 5, 2022 22:18
@snippet-bot
Copy link

snippet-bot bot commented Apr 5, 2022

Here is the summary of possible violations 😱

There is a possible violation for not having product prefix.

The end of the violation section. All the stuff below is FYI purposes only.


Here is the summary of changes.

You are about to add 1 region tag.

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 size: m Pull request size is medium. api: cloudoptimization Issues related to the googleapis/python-optimization API. samples Issues that are directly related to samples. labels Apr 5, 2022
@leahecole
Copy link
Contributor

I'm noticing that samples tests are passing but aren't actually running due to the lack of noxfile. I've flagged this to @googleapis/python-samples-owners as a concern to address. I'll send you individual instructions for running local samples tests as a workaround.

@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 Apr 6, 2022
Copy link
Contributor

@leahecole leahecole left a comment

Choose a reason for hiding this comment

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

I added a few comments, but I also have a few overall requests

  • Please add a requirements.txt file to the same directory your samples are in with libraries needed for your sample to run and have them pinned to specific versions (for example - https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/composer/rest/requirements.txt)
  • Please add a requirements.txt file to the same directory your samples are in with libraries needed for tests to run. It will likely be identical to this one since your test doesn't call any additional 3rd party libraries (https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/composer/rest/requirements-test.txt)
  • Please add a noxfile-config.py file to the directory where your samples are. This will enforce type hinting and specify which versions of Python to test in (by default, we test in 3.7, 3.8, 3.9, and 3.10. If your product does not support one of those versions, please exempt it in this file by adding the version to the list with 2.7 and 3.6). You can copy this file directly. This configuration file will interact with a noxfile that will be generated once a requirements file is present. The noxfile configures nox, our test runner
  • Please add type hints, they are required per the authoring guide

@leahecole leahecole added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@changsongd changsongd requested a review from a team as a code owner April 6, 2022 18:38
@leahecole
Copy link
Contributor

@changsongd I pinged you about why the noxfile reappeared! one that was generated SHOULD be there now - sorry - so confusing, I know!

@changsongd
Copy link
Contributor Author

@changsongd I pinged you about why the noxfile reappeared! one that was generated SHOULD be there now - sorry - so confusing, I know!

Oh, I think I accidentally deleted it. Will the OwlBot be triggered again and re-generate that file?

@leahecole leahecole added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@leahecole leahecole added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 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 Apr 6, 2022
@leahecole
Copy link
Contributor

I've now enabled the maps plugin and will retry

@leahecole leahecole added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@leahecole
Copy link
Contributor

Weird, I'm seeing 403s on two versions of Python but not on two others? 🤔 I'll try a re-run to see if it's consistent

@leahecole leahecole added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@leahecole leahecole added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@leahecole
Copy link
Contributor

Still trying to get the samples lint check to show up

@parthea parthea added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 6, 2022
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 6, 2022
@leahecole leahecole added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@leahecole
Copy link
Contributor

trigger owlbot because it looks a lil stuck

@leahecole leahecole merged commit c3d6087 into googleapis:main Apr 6, 2022
@changsongd changsongd deleted the add_samples_with_json_request branch April 6, 2022 21:22
changsongd added a commit to changsongd/python-optimization that referenced this pull request Apr 6, 2022
* add code snippets for sync and async api

* remove async test samples

* use f-string

* change project_id to input arg

* add noxfile

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* rename noxfile and add requirements

* rm noxfile

* rm noxfile local

* add root noxfile

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>

* Apply suggestions from code review

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Add commit to trigger kokoro

* add indentation

* add type annotations

Co-authored-by: Jeffrey Rennie <rennie@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
busunkim96 added a commit that referenced this pull request Apr 8, 2022
* Add get_operation code snippets

* update comment

* docs: add sync api samples with json request (#13)

* add code snippets for sync and async api

* remove async test samples

* use f-string

* change project_id to input arg

* add noxfile

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* rename noxfile and add requirements

* rm noxfile

* rm noxfile local

* add root noxfile

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>

* Apply suggestions from code review

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* Update noxfile.py

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Add commit to trigger kokoro

* add indentation

* add type annotations

Co-authored-by: Jeffrey Rennie <rennie@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>

* rebase and add type annotations

* fix operation_id type

* Update samples/snippets/get_operation.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

* Update samples/snippets/get_operation_test.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

* move TODO outside func, create operation in test

* lint fix

* fix asyncmodelconfig

* change model_config to list

* add blank line

* change request to dict

* change parent to project id

* remove model config

* Update samples/snippets/get_operation.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

* add TODO back

Co-authored-by: Jeffrey Rennie <rennie@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: cloudoptimization Issues related to the googleapis/python-optimization 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.

None yet

6 participants