-
Notifications
You must be signed in to change notification settings - Fork 3
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
KK-1108 | Upgrade to Django 4.2 & upgrade all packages to latest #390
Conversation
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
642aa6d
to
66044b0
Compare
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
66044b0
to
09a3d02
Compare
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
4e3d3e7
to
572e845
Compare
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
5a43a5e
to
fa9e434
Compare
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
done: - upgrade postgres from 11 to 12 - required, didn't work without this change - change import paths - graphql.execution.base.ResolveInfo -> graphql.type.GraphQLResolveInfo - add arbitrary primary keys to objects used in dummy notification contexts because factory's build doesn't create a primary key yet, and without it generating the URLs using the object's ID fails - remove QUERY_TOO_DEEP_ERROR and DepthAnalysisBackend, use graphene's depth_limit_validator instead which should give a GraphQLError like `<operation_name> exceeds maximum operation depth of <max_depth>. - fix executed_graphql_request() has no `invalid` member - fix graphene enums to work similarly to graphene v2 -> using values - graphene v3 changed enums so they work differently than in graphene v2, forcing backward compatibility by converting enums to their values - fix using django-parler translations, map enums to their values - fix enums in TranslatableQuerySet objects, map them to their values refs KK-1108
6a3f567
to
f9a8200
Compare
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KK-1108 1. The version property is now obsoleted in the docker compose config. 2. Since the Postgre is upgraded with a new major release, the database will need a migration for the existing data. To skip this, we can create a new database in different volume location. This is quite common aproach.
KK-1108. Re-add the protocol and occurrences filters that were earlier removed, because they were hard to fix (during the upgrade process).
I think the piipeline changes are only thing that is still missing from the API update. Sure we need to offer supportive schema for both the UI clients too!
|
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is failed for https://kukkuu-pr390.api.dev.hel.ninja 😿💢💥💥 |
KK-1108. Browser tests found a bug in the event group creation from admin site.
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.
There seems to be a built-in way to handle the enum-values! I'll try this in a new PR, so we could get rid of our custom code, that seems to work OK, but brins some custom duplicated boilerplate code that we don't need to have under maintenance.
def is_enum_value(value): | ||
""" | ||
Check if a value is an enum value, e.g. TestEnum.FI | ||
where TestEnum derives from enum.Enum or graphene.Enum. | ||
""" | ||
# Works both for enum.Enum and graphene.Enum | ||
return type(type(value)) is enum.EnumMeta | ||
|
||
|
||
def deepfix_enum_values(data): | ||
""" | ||
Fix enum values recursively in/out of dictionaries, lists, sets, and tuples. | ||
""" | ||
if isinstance(data, dict): | ||
return {deepfix_enum_values(k): deepfix_enum_values(v) for k, v in data.items()} | ||
elif isinstance(data, (list, set, tuple)): | ||
return type(data)(deepfix_enum_values(v) for v in data) | ||
elif is_enum_value(data): | ||
return data.value | ||
else: | ||
return data | ||
|
||
|
||
def map_enums_to_values_in_kwargs(method): | ||
""" | ||
Decorator that maps enums to their values in keyword arguments. | ||
""" | ||
|
||
def wrapper(*args, **kwargs): | ||
fixed_kwargs = deepfix_enum_values(kwargs) | ||
return method(*args, **fixed_kwargs) | ||
|
||
return wrapper |
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.
@karisal-anders did you test this feature https://docs.graphene-python.org/projects/django/en/latest/queries/#choices-to-enum-conversion? What about setting the convert_choices_to_enum = False
?
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.
@karisal-anders did you test this feature https://docs.graphene-python.org/projects/django/en/latest/queries/#choices-to-enum-conversion? What about setting the
convert_choices_to_enum = False
?
No, I didn't come across that feature. If it works let's use that instead.
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.
It did not work right just how was expected, because it still had issues with the uppercase formatting. While the uppercase formatting is still an issue, it does not make sense to stick with the string inputs, when the enums offers better typing and hinting. I created a new PR of the changes #399. We can take that in action later if needed or wanted.
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is success for https://kukkuu-pr390.api.dev.hel.ninja 😆🎉🎉🎉 |
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is success for https://kukkuu-pr390.api.dev.hel.ninja 😆🎉🎉🎉 |
8740ffc
to
2084067
Compare
|
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.
All the checks are now green -- even the browser tests! 👍
The schema updates are City-of-Helsinki/kukkuu-admin#276 and City-of-Helsinki/kukkuu-ui#581.
There is an alternative approach for this: #399 and City-of-Helsinki/kukkuu-admin#277 uses the enums as preferred.
KUKKUU-API branch is deployed to platta: https://kukkuu-pr390.api.dev.hel.ninja 🚀🚀🚀 |
TestCafe result is success for https://kukkuu-pr390.api.dev.hel.ninja 😆🎉🎉🎉 |
Description
REQUIRES PIPELINES TO BE CHANGED FROM POSTGRES 11 TO 12 in these files:
by changing
image: postgres:11
toimage: postgres:12
.feat: upgrade Django to 4.2 & upgrade all packages to latest
done:
graphql.type.GraphQLResolveInfo
contexts because factory's build doesn't create a primary key yet,
and without it generating the URLs using the object's ID fails
depth_limit_validator instead which should give a GraphQLError like
`<operation_name> exceeds maximum operation depth of <max_depth>.
invalid
membergraphene v2, forcing backward compatibility by converting enums
to their values
refs KK-1108
Related
KK-1108
Graphene 3 changed from using enum values to enums, for example:
would've been serialized previously using the enum values, i.e.
'first' and 'second'. But with Graphene 3 they are serialized as
'TestEnum.FIRST' and 'TestEnum.SECOND'. This broke functionality as
parts of the codebase were expecting the enum values as per Graphene 2.
Forced backwards compatibility by forcefully mapping enums to their
values.
Related https://github.com/graphql-python/graphene issues & PRs:
of the enum values" issue:
See https://github.com/graphql-python/graphene/wiki/v3-release-notes
for Graphene v3's breaking changes,
Manual testing
Running
pytest . -vv
in docker container locally everything passes: