-
Notifications
You must be signed in to change notification settings - Fork 27
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
Simulator resources creation #2041
base: simulator-resources
Are you sure you want to change the base?
Simulator resources creation #2041
Conversation
return self._create_multiple( | ||
list_cls=SimulatorModelList, | ||
resource_cls=SimulatorModel, | ||
items=models, | ||
input_resource_cls=SimulatorModelWrite, | ||
resource_path="/simulators/models", | ||
) |
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 this operation to work you have to set limit=1
otherwise this request will fail when multiple models are passed in.
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.
Set self._CREATE_LIMIT = 1
in __init__
and this will be taken care of automatically.
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 base resource_path
here should be set as a class variable, I believe _RESOURCE_PATH
. Then you can use:
resource_path=self._RESOURCE_PATH,
# ...and similarity for other endpoints, e.g.:
resource_path=self._RESOURCE_PATH + "/revisions",
return self._create_multiple( | ||
list_cls=SimulatorModelList, | ||
resource_cls=SimulatorModel, | ||
items=revisions, | ||
input_resource_cls=SimulatorModelRevisionWrite, | ||
resource_path="/simulators/models/revisions", | ||
) | ||
|
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 this operation to work you have to set limit=1
otherwise this request will fail when multiple models are passed in.
return self._update_multiple( | ||
list_cls=SimulatorModelList, resource_cls=SimulatorModel, update_cls=SimulatorModelUpdate, items=item | ||
) |
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.
_update_multiple
doesn't accept limit
param (basically the chunk size).
_UPDATE_LIMIT
is set to 1000 but our API only supports one at a time.
However, if we can't customize _UPDATE_LIMIT
like the create_multiple, the request will fail, but that should not be a big deal. We can keep this as a it is
…nitedata/cognite-sdk-python into simulator-resources-creation
Co-authored-by: Everton Colling <[email protected]>
Co-authored-by: Everton Colling <[email protected]>
Co-authored-by: Ivan Polomani <[email protected]>
Description
Please describe the change you have made.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.