-
Notifications
You must be signed in to change notification settings - Fork 83
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
[NHUB-540] Add async ResourceModel for ContentAPI items #2740
Conversation
… once looping completed
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.
Looks good, just left two minor comments.
planning_id: fields.Keyword | None = None | ||
coverage_id: fields.Keyword | None = None | ||
agenda_id: fields.Keyword | None = None | ||
agenda_href: fields.Keyword | None = None |
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'm seeing so many of these fields.Keyword | None = None
. Would it make sense to have something like this:
# first define a optional keyword field type
OptionalKeyword = Annotated[fields.Keyword | None, Field(default=None)]
# and then reuse it like
event_id: OptionalKeyword
planning_id: OptionalKeyword
coverage_id: OptionalKeyword
# and so on
I didn't test this, it's just a thought. What do you think?
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 this and MyPy does't like it, it thinks that no default value is supplied and complains when another field with an = None
before if:
Attributes without a default cannot follow attributes with one
media: Any | ||
|
||
mail: Any | ||
|
||
data: Any | ||
|
||
storage: Any | ||
|
||
auth: Any | ||
|
||
subjects: Any | ||
|
||
notification_client: NotificationClientProtocol | ||
|
||
locators: Any | ||
|
||
celery: Any | ||
|
||
redis: Any | ||
|
||
jinja_loader: Any | ||
|
||
jinja_env: Any |
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.
are we going to provide types for these in the future?
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.
Ideally we would not use this at all, by replacing the required functionality into the new async app. For example, data
will no longer be required as we have equivalent in the new async app.
Purpose
Create async ResourceModel for ContentAPI items, and implement publish code to it as simple functions (for re-use with Newshub). Also small changes required by the Newshub Wire async upgrade task.
What has changed
projection
argument to asyncfind_one_
based functionsinclude_in_parent
elasticsearch configvalidate_iunique_value_async
without requiring to addresource_name
and possiblyfield_name
, making it easier to use. Will do this lateris_json_request
to Request instance