cesbit / aiogcd Goto Github PK
View Code? Open in Web Editor NEWAsync Google Cloud Datastore API
License: MIT License
Async Google Cloud Datastore API
License: MIT License
Greetings!
Is there a way to create excluded from indexes properties with ORM Layer? Looks like there's a way to create them with aiogcd.connector.entity
, but it's kinda low level.
Function fromstring
is deprecated. Use frombytes
instead.
Add type bytesValue
to the ORM layer as it is possible to insert bytes values.
Within GCD a bytesValue will be stored as a blobValue.
When no GcdModel is used, the function get_entities_by_kind
should support an offset
, limit
and thus cursor
to query entities in batches.
Since this requires a cursor
, the result of the function should depend on the limit
argument. When None
, the "old" behavior should be honored for backwards compatibility. When a limit is set, the function should return a (list, cursor)
tuple.
Namespaces are currently not supported by aiogcd.
Replace tostring
as this method is deprecated
A token file is not created if a path for the token file is missing.
service_account_token.py
async with ensure_session(self.session) as s:
response = await s.post(
url,
data=payload,
headers=headers,
timeout=60
)
return await response.json()
causes infinite loop in some requests, changing to:
async with ensure_session(self.session) as s:
response = await s.post(
url,
data=payload,
headers=headers,
timeout=60
)
json = await response.json()
return json
helps
When using a limit and hitting the NOT_FINISHED
, the offset value should be removed as this should be used in the first request only
The fix to download blobValues (bytes) is not totally correct, see error below:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "some.py", line 123, in func
values, cursor = await _gcd.get_entities_by_kind(
File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 333, in get_entities_by_kind
return await self._get_entities_cursor(data)
File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 280, in _get_entities_cursor
return [Entity(result['entity']) for result in results], cursor
File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 280, in <listcomp>
return [Entity(result['entity']) for result in results], cursor
File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/entity.py", line 44, in __init__
setattr(self, prop, value_from_dict(val))
File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/utils.py", line 81, in value_from_dict
(val + pad).replace(b'-', b'+').replace(b'_', b'/'))
TypeError: can only concatenate str (not "bytes") to str
One important feature of obtaining an entity by its key is that the read_consistency
is strong. In the case of a global query, read_consistency
is eventual
and could result in undesired consequences depending on ones expectation of the library function's behaviour. Based on the REST API, implementing lookup
would provide both get_entity_by_key
and get_entities_by_keys
for free (having one implies having the other). Luckily, json.dumps(<key>.get_dict())
should provide the right shape of data required for the lookup
REST API :-)
I think it would be good to emulate the behaviour of this function in the official python module code (synchronous).
I would be happy to open a PR for this, but am not sure when I'll have time to do so. Logging this here in case someone wants to take a crack at it before I have the chance!
For reference/reading:
aiogcd lookup implementation
GCloud API Doc - lookup
Pull request #8 introduced a yield inside async function
error.
Thanks for this library!
Any plans for disjunctive/conjunctive queries? e.g., filtering list fields for multiple values?
Thanks for this project, excited to have found it!
Is there a way to use service accounts (with JSON key) to authorize requests with this lib? Happy to work on adding this functionality if there is a known path!
When omitting the __kind__
property in a model class, the kind for the model is not set correctly.
We expect the following model:
class User(GcdModel):
...
... to have kind User, just like this model:
class TestUser(GcdModel):
__kind__ = 'User'
But instead the first class sets kind None
.
The following functions are missing an await call for getting the result:
When using a filter with an ArrayValue
it seems to fail:
TypeError: Expecting a value of type 'int'...
The ArrayType
requires a special way of filtering, for example:
Suppose there exists an entity with an arr
property with the array
[123, 456, 789]
The following should return that entity:
Entity.filter(Entity.arr == 456)
When executing the insert_alice
example, I receive the following error:
IndexError: Both "id" and "name" are missing in pair: {'kind': 'User'}
Currently, the function get_entities_by_keys
returns None
when no entities are found.
It makes much more sense to always return a list
, and just an empty list if no entities are found.
Function run_query
is missing an await
call for getting the result.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.