-
Notifications
You must be signed in to change notification settings - Fork 11
ResourceMgr: Move methods to models #25
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
Conversation
eg-firebolt
commented
Oct 12, 2021
- clean up logging (do not log exceptions by default for security/privacy)
- refactor models
- https://packboard.atlassian.net/browse/FIR-8023
- https://packboard.atlassian.net/browse/FIR-8024
|
In https://packboard.atlassian.net/browse/FIR-8023, you asked for a method named An easy workaround is simply to use But I wonder if we should stay away from using EDIT: we decided to use |
| ) | ||
|
|
||
| @classmethod | ||
| def parse_obj_with_service(cls, obj: Any, engine_service: EngineService) -> Engine: |
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.
nit: _engine_service, _database_service -> _service and move this method to FireboltBaseModel
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 tried moving to FireboltBaseModel, but its not so easy to make this generic, because when you call self._service.get(..) we don't know if we are talking getting an engine or a database or something else.
I am going to leave this mostly as-is for now. We can look at it together at some point.
| f"Engine (engine_id={engine.engine_id}, name={engine.name}) stopped." | ||
| ) | ||
|
|
||
| engine = self._send_start() |
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.
What will happen if engine is already started? Would it error if you try to start it again?
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.
| response = self.client.post( | ||
| url=f"/core/v1/accounts/{self.account_id}/databases", | ||
| headers={"Content-type": "application/json"}, | ||
| json=_DatabaseCreateRequest( |
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.
could we simply pass a dictionary here?
why do we need a _DatabaseCreateRequest?
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 could do a dictionary instead, we don't need a _DatabaseCreateRequest, however, I kind of like it because it's explicit about types that are expected in the request and whether or not they are optional. It also prevents me from having to call .jsonable_dict in multiple places.
This becomes a bit more useful in the engine case than the database case. Here's what it would probably look like as a dict in the engine case:
response = self.client.post(
url="/core/v1/account/engines",
headers={"Content-type": "application/json"},
json=prune_dict(
dict(
account_id=self.account_id,
engine=engine.jsonable_dict(by_alias=True),
engine_revision=engine_revision.jsonable_dict(by_alias=True) if engine_revision else None
)
)
)All that being said, if you like the dict way a lot more, I can take out the helper models
|
General comment: This PR came out to be pretty big, I would ask to split such PRs into smaller ones in future. This way it would be easier to understand/review them. For example, this one could be splitted by changes for each instance type |

