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
feat!: Leverage new generator, proto-plus, for google-cloud-datastore #104
Merged
Merged
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
2990592
feat: generated new surfaces, remove old generated surface
crwilcox 9585e3f
chore: add fixup script for admin api
crwilcox 894ba30
fix: change gapic name, regenerate
crwilcox 5bc0dcc
chore: cleanup synth.py
crwilcox 524ca4b
chore: move generated source over old generated source
crwilcox 58e7624
fix: ran fix script on v1
crwilcox 4d5e5ff
chore: add new gen source to repository
crwilcox 3366314
test: temporarily move 'test_gapic'
crwilcox 98e6985
test: run fixup scripts on tests
crwilcox ee47dd5
fix:replaces _pb2 calls with types
crwilcox 300472e
fix: manually template coveragerc
crwilcox b4d006a
docs: update to include 3.9, discontinue 2.7, 3.5
crwilcox fbb5af5
fix:regenerate from synth.py
crwilcox cc74b0f
fix: resynth
crwilcox 9a82572
fix: undo fixes to manual surface
crwilcox 0fbd6a3
fix: 63 failures on unit-3.8
crwilcox d936710
fix: tests passing for unit-3.8
crwilcox 905e0d8
fix: blacken
crwilcox 42c9efb
Merge branch 'master' into new-generator
crwilcox 3838686
fix: some changes to fix system tests
crwilcox be9ea01
test: update noxfile python versions
crwilcox da8300d
fix: changes for system tests
crwilcox 158f676
docs: fix doc string to allow docs builds, remove 3.9 until is supported
crwilcox 065f7ee
fix: repair unit tests that failed after bringing code in line with s…
crwilcox 7388f1d
chore: lint
crwilcox 8106ed3
test: bring gapic test back, update coveragerc, remove py2 conditionals
crwilcox 5d2a64b
chore: lint
crwilcox a8a4243
chore: lint
crwilcox 3ccb514
fix: rollback call
crwilcox 70d8f30
fix: a few odd calls fixed up
crwilcox 0822cbe
test: fix two tests and lint
crwilcox d020260
chore: refactor use of _pb to single location for _http
crwilcox 36240bb
chore: refactor more _pb away
crwilcox fadbaf9
chore: refactor _pb out more.
crwilcox af85cad
chore: refactor _pb out more.
crwilcox 0e266ff
chore: refactor _pb out more.
crwilcox 491c5f5
chore: blacken/lint
crwilcox File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Datastore Admin Client | ||
====================== | ||
|
||
.. automodule:: google.cloud.datastore_admin_v1.gapic.datastore_admin_client | ||
.. automodule:: google.cloud.datastore_admin_v1.services.datastore_admin.client | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ | |
|
||
from google.cloud._helpers import _datetime_to_pb_timestamp | ||
from google.cloud._helpers import _pb_timestamp_to_datetime | ||
from google.cloud.datastore_v1.proto import datastore_pb2 | ||
from google.cloud.datastore_v1.proto import entity_pb2 | ||
from google.cloud.datastore_v1.types import datastore as datastore_pb2 | ||
from google.cloud.datastore_v1.types import entity as entity_pb2 | ||
from google.cloud.datastore.entity import Entity | ||
from google.cloud.datastore.key import Key | ||
|
||
|
@@ -86,7 +86,14 @@ def _new_value_pb(entity_pb, name): | |
:rtype: :class:`.entity_pb2.Value` | ||
:returns: The new ``Value`` protobuf that was added to the entity. | ||
""" | ||
return entity_pb.properties.get_or_create(name) | ||
properties = entity_pb.properties | ||
try: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Later in the same file, you do the same thing at line 396 but in a different way. Maybe a function to standardize the spelling here would be in order.
|
||
properties = properties._pb | ||
except AttributeError: | ||
# TODO(microgenerator): shouldn't need this. the issue is that | ||
# we have wrapped and non-wrapped protos coming here. | ||
pass | ||
return properties.get_or_create(name) | ||
|
||
|
||
def _property_tuples(entity_pb): | ||
|
@@ -211,7 +218,7 @@ def entity_to_protobuf(entity): | |
entity_pb = entity_pb2.Entity() | ||
if entity.key is not None: | ||
key_pb = entity.key.to_protobuf() | ||
entity_pb.key.CopyFrom(key_pb) | ||
entity_pb._pb.key.CopyFrom(key_pb._pb) | ||
|
||
for name, value in entity.items(): | ||
value_is_list = isinstance(value, list) | ||
|
@@ -256,7 +263,7 @@ def get_read_options(eventual, transaction_id): | |
if transaction_id is None: | ||
if eventual: | ||
return datastore_pb2.ReadOptions( | ||
read_consistency=datastore_pb2.ReadOptions.EVENTUAL | ||
read_consistency=datastore_pb2.ReadOptions.ReadConsistency.EVENTUAL | ||
) | ||
else: | ||
return datastore_pb2.ReadOptions() | ||
|
@@ -386,6 +393,10 @@ def _get_value_from_value_pb(value_pb): | |
:raises: :class:`ValueError <exceptions.ValueError>` if no value type | ||
has been set. | ||
""" | ||
if getattr(value_pb, "_pb", False): | ||
# TODO(microgenerator): fix inconsistent calling. | ||
value_pb = value_pb._pb | ||
|
||
value_type = value_pb.WhichOneof("value_type") | ||
|
||
if value_type == "timestamp_value": | ||
|
@@ -419,7 +430,7 @@ def _get_value_from_value_pb(value_pb): | |
|
||
elif value_type == "geo_point_value": | ||
result = GeoPoint( | ||
value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude | ||
value_pb.geo_point_value.latitude, value_pb.geo_point_value.longitude, | ||
) | ||
|
||
elif value_type == "null_value": | ||
|
@@ -450,15 +461,16 @@ def _set_protobuf_value(value_pb, val): | |
""" | ||
attr, val = _pb_attr_value(val) | ||
if attr == "key_value": | ||
value_pb.key_value.CopyFrom(val) | ||
value_pb.key_value.CopyFrom(val._pb) | ||
elif attr == "timestamp_value": | ||
value_pb.timestamp_value.CopyFrom(val) | ||
elif attr == "entity_value": | ||
entity_pb = entity_to_protobuf(val) | ||
value_pb.entity_value.CopyFrom(entity_pb) | ||
# value_pb._pb.entity_value.CopyFrom(entity_pb._pb) | ||
value_pb.entity_value.CopyFrom(entity_pb._pb) | ||
elif attr == "array_value": | ||
if len(val) == 0: | ||
array_value = entity_pb2.ArrayValue(values=[]) | ||
array_value = entity_pb2.ArrayValue(values=[])._pb | ||
value_pb.array_value.CopyFrom(array_value) | ||
else: | ||
l_pb = value_pb.array_value.values | ||
|
Oops, something went wrong.
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.
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.
This is really a comment for the generator and not this particular PR, but in general, I'm in favor of clearly marking files which are generated. (I'm assuming this file is still generated.) The less detective work you can make a developer do, the better.
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.
This goes for everything under
services
andtypes
, too. Or maybe it could be a README in those folders. But a clear delineation between generated and hand written code, I think, is helpful.