GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Bigtable Autoscaler sample by waprin · Pull Request #943 · GoogleCloudPlatform/python-docs-samples

Conversation

@waprin

@waprin waprin commented May 13, 2017

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mbrukman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Bill Prin added 3 commits May 12, 2017 17:48
Bill Prin
Add Bigtable Autoscaler sample
8e85287
Bill Prin
update readme
dbffb15
Bill Prin
add return type to docstring
0ab3bc5
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 13, 2017
Bill Prin
remove trailing whitespace
8078667
@waprin
waprin requested a review from ace-n May 13, 2017 00:53
@waprin waprin mentioned this pull request May 13, 2017
Add Autoscaler Example GoogleCloudPlatform/cloud-bigtable-examples#224
Closed
@waprin
waprin removed the request for review from ace-n May 13, 2017 00:54
@waprin

waprin commented May 13, 2017

Copy link
Copy Markdown
Contributor Author

@rameshdharan thinking this sample is better here

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@waprin
waprin requested review from theacodes and tswast May 13, 2017 00:54
Bill Prin added 2 commits May 12, 2017 17:57
Bill Prin
Fix main call
dc4b23a
Bill Prin
fix instance flag name
1ea09fe
mbrukman
mbrukman reviewed May 13, 2017
View reviewed changes
Comment thread bigtable/autoscaler/strategies_test.py

def test_downscale():
downscale_strategy = DOWNSCALE_STRATEGIES['incremental']
assert downscale_strategy(5) == 3

@mbrukman mbrukman May 13, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

How do you run these tests without using the unittest module? Are they imported somewhere into a main file which runs all the tests?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 13, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Our main test runner is pytest which scans for functions that start with test_ and handles the Python asserts in a way similar to how unittest would the assert functions, so it's pretty neat.

If you do:

pip install pytest
pytest

it will run all the tests.

In this specific repo, since there's dozens of samples ,we use nox which helps instrument different sessions etc. But really in here it will just call pytest.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
theacodes
theacodes previously requested changes May 15, 2017
View reviewed changes
Comment thread bigtable/autoscaler/autoscaler.py Outdated

import strategies

CPU_METRIC = 'bigtable.googleapis.com/cluster/cpu_load'

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

while constants are good practice in production code, in sample code they add a layer of indirection that can be annoying when including a snippet in cloud site. Strongly prefer this to go near where it's used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread bigtable/autoscaler/autoscaler.py Outdated
"""
client = monitoring.Client()
query = client.query(CPU_METRIC, minutes=5)
return list(query)[0].points[0].value

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

For sample code, prefer pulling out discrete values and giving them names:

results = client.query(CPU_METRIC, minutes=5)
results = list(query)
first_result = results[0]
cpu_load = first_result.points[0].value

Also, shouldn't that query have a limit of 1?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done. API doesn't support limits on queries.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread bigtable/autoscaler/autoscaler.py Outdated

Args:
bigtable_instance (str): Cloud Bigtable instance id to scale
up (bool): If true, scale up, otherwise scale down

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd recommend scale_up as a more more descriptive name. Then, you can probably drop the args section and just describe the behavior in the description.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

scale_up seems misleading in the case of downscale.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And up is less misleading?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry, misunderstood, thought you meant the function name. Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread bigtable/autoscaler/autoscaler.py
default=60 * 10)
args = parser.parse_args()

while True:

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

move the while to main.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I had it in main, but I moved it out here to make it easier to test main. Otherwise testing while True loops is annoying. Would probably have to make a bunch of changes just to test the code, this seemed like the simpler option.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The tests shouldn't influence flow control. We can figure out how to break out of the loop. Likely by using mock to insert a keyboard interrupt.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread bigtable/autoscaler/strategies.py
@@ -0,0 +1,50 @@
# Copyright 2017 Google Inc.

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Any reason to have this as a separate file? For the sake of samples, it seems it would be most useful to locate this near the code that uses these strategies.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The idea is we are going to add a few alternative strategies such as exponential, and have them all organized in here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@theacodes theacodes May 15, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I see. If that's valuable and matches with how this will be presented in the docs, then that's fine.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@waprin waprin May 15, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ya doc is still a WIP so once we have a draft of that I'll take another look at this and if it's pointlessly complicating things I'll move it back into autoscaler.py.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Bill Prin added 6 commits May 15, 2017 13:37
Bill Prin
style and jonwayne review
bd69e29
Bill Prin
lint and jonwayne
7e70fa8
Bill Prin
fix tests
fcc66e3
Bill Prin
fix tests
c2c3ff8
Bill Prin
fix tests
87b0652
Bill Prin
fix reqs
2b4f39d
@waprin
waprin dismissed theacodes’s stale review May 16, 2017 07:55

noted

@waprin
waprin merged commit 47baea9 into master May 16, 2017
@theacodes

theacodes commented May 16, 2017

Copy link
Copy Markdown
Contributor

@waprin why was this merged? There was at least one outstanding comment that I wanted to resolve before we merged.

I'm usually fine with compromises in the near term as long as we create bugs to follow up, but dismissing my review and merging does not seem like our usual mode of operation. What's the rush to merge this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes
theacodes deleted the bigtable_autoscaler branch June 28, 2017 16:06
@Linchin Linchin mentioned this pull request Aug 18, 2025
chore: migrate handwritten samples from googleapis/python-bigquery-storage #13543
Merged
9 tasks
Linchin added a commit that referenced this pull request Aug 18, 2025
@renovate-bot @Linchin
chore(deps): update all dependencies (#943)
d44d4cb
* chore(deps): update all dependencies

* Update docs.yml

* Update lint.yml

* Update requirements.txt

---------

Co-authored-by: Lingqing Gan <[email protected]>
@chalmerlowe chalmerlowe mentioned this pull request Apr 7, 2026
migrate code from googleapis/python-storage #13989
Merged
9 tasks
chalmerlowe pushed a commit that referenced this pull request Apr 7, 2026
@andrewsg
feat: Add "transfer_manager" module for concurrent uploads and downlo…
e8d6c13
…ads, as a preview feature (#943)

* checkpoint before design doc impl

* checkpoint

* more tests

* code and tests for transfer manager complete

* proactively close temp files when finished reading

* respond to comments; destroy tmp files as they are consumed

* Add system tests, docstrings, address feedback

* Respond to review comments

* verify md5 hash of downloaded file in test

* lint

* default empty strings for root arguments

* fix bug with blob constructor

* add warning about files not being deleted if their downloads fail

* docs: Add samples to multithread branch (#918)

* add samples, tests pending

* add snippet tests

* snippet and snippets_test.py linting

* snippets; recursive directory creation; rename some params

* Add directory upload snippet

* fix: remove chunked downloads; change max_workers to threads

* update snippets to add thread info

* fix snippets test issue due to change in dependency

* snippet nomenclature

* fix samples for real this time
@parthea parthea mentioned this pull request Sep 8, 2026
migrate code from googleapis/python-bigquery #14589
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tswast tswast Awaiting requested review from tswast
2 more reviewers
@theacodes theacodes theacodes left review comments
@mbrukman mbrukman mbrukman left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@waprin @theacodes @mbrukman @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.