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

Reserve_ids documentation has a typo, and implementation seems bugged #37

Closed
aawilson opened this issue Jun 12, 2020 · 7 comments · Fixed by #36 or #76
Closed

Reserve_ids documentation has a typo, and implementation seems bugged #37

aawilson opened this issue Jun 12, 2020 · 7 comments · Fixed by #36 or #76
Assignees
Labels
api: datastore Issues related to the googleapis/python-datastore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@aawilson
Copy link
Contributor

I've omitted all the usual fields because I feel they are irrelevant, I hope that is okay. Please refer to the PR here: #36

One basic issue is that the documentation of reserve_ids doesn't match the the typespec. The other issue is that the documentation overall is ambiguous enough that I'm actually not sure of its behavior. I would expect it to sequentially reserve all IDs starting from the provided complete key, up to a count of "num", but since all it passes to the underlying API is [complete_key] * num I'm actually not positive that that's what it's doing, or even what it's exactly doing, without anything further to refer to.

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-datastore API. label Jun 12, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 13, 2020
@IlyaFaer IlyaFaer added type: docs Improvement to the documentation for an API. and removed triage me I really want to be triaged. labels Jun 15, 2020
@aawilson
Copy link
Contributor Author

The more I look at the reserveIds API, the more convinced I am that the behavior at this line is completely wrong, in a way that's so weirdly obvious that I'm having trouble believing that I'm not mistaken. Can someone confirm whether or not that is the case? Just to note:

>>> key=c.key('User',111)
>>> complete_key=c.key('User',111)
>>> complete_key_pb = complete_key.to_protobuf()
>>> complete_key_pbs = [complete_key_pb] * 5
>>> complete_key_pbs
[partition_id {
  project_id: "olark-staging"
  namespace_id: "site"
}
path {
  kind: "User"
  id: 111
}
, partition_id {
  project_id: "olark-staging"
  namespace_id: "site"
}
path {
  kind: "User"
  id: 111
}
, partition_id {
  project_id: "olark-staging"
  namespace_id: "site"
}
path {
  kind: "User"
  id: 111
}
, partition_id {
  project_id: "olark-staging"
  namespace_id: "site"
}
path {
  kind: "User"
  id: 111
}
, partition_id {
  project_id: "olark-staging"
  namespace_id: "site"
}
path {
  kind: "User"
  id: 111
}
]
>>>   

@aawilson
Copy link
Contributor Author

It seems to me like the client method should accept a list of complete keys, not a single "basis" key, and should not accept a "num" argument at all.

@aawilson aawilson changed the title Reserve_ids documentation has a typo, and also feels incomplete Reserve_ids documentation has a typo, and implementation seems bugged Jun 22, 2020
@aawilson
Copy link
Contributor Author

@IlyaFaer I've updated the issue with some additional concerns that are not just centered around documentation. I think this implementation is wrong but cannot confirm the intended behavior because I don't have any special insight into GCD's behavior.

@aawilson
Copy link
Contributor Author

Pinging this since it's been a month.

@aawilson
Copy link
Contributor Author

aawilson commented Aug 5, 2020

@tseaver Hello! Thanks for accepting the documentation patch, but I think there is more to this issue. Could someone from the team please have a look at #37 (comment) and tell me if I'm crazy or not?

@aawilson
Copy link
Contributor Author

aawilson commented Aug 5, 2020

tl;dr: I'm pretty sure it's constructing a request with a list of ids like

[(Kind, start_id), (Kind, start_id), ...]  # to length num

when it should be like

[(Kind, start_id), (Kind, start_id + 1), ... (Kind, start_id + num - 1)]

Am I reading it wrong, or is this bugged?

@tseaver tseaver reopened this Aug 7, 2020
@tseaver
Copy link
Contributor

tseaver commented Aug 7, 2020

OK, looking at Client.reserve_ids, I agree that the implementation is problematic (it should be bumping the numeric key for each subsequent key created). For backward compatibility, we should:

  • Rename the current implementation to reserve_ids_sequential, and fix it to create the correct numeric values.
  • Make reserve_ids a deprecated alias for reserve_ids_sequential.
  • Add a new method, reserve_ids_multiple (name?), which just takes a sequence of complete keys.

@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: docs Improvement to the documentation for an API. labels Aug 7, 2020
chrisrossi pushed a commit to chrisrossi/python-datastore that referenced this issue Aug 25, 2020
`Client.reserve_ids` has been reimplemented in a way that should be a lot more
useful, and has been renamed `Client_reserve_ids_sequential`, leaving
the old name as a deprecated alias.

`Client.reserve_ids_multi` has been added, which takes sequence of
complete keys to reserve.

Fixes googleapis#37
tseaver pushed a commit that referenced this issue Sep 2, 2020
`Client.reserve_ids` has been reimplemented in a way that should be a lot more
useful, and has been renamed `Client_reserve_ids_sequential`, leaving
the old name as a deprecated alias.

`Client.reserve_ids_multi` has been added, which takes sequence of
complete keys to reserve.

Fixes #37
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. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
5 participants