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

change in pydantic v2 #81

Closed
AlothNaveen opened this issue Dec 13, 2023 · 3 comments · Fixed by #82
Closed

change in pydantic v2 #81

AlothNaveen opened this issue Dec 13, 2023 · 3 comments · Fixed by #82
Assignees
Labels
bug Something isn't working

Comments

@AlothNaveen
Copy link

:~/b/rt-5gms-application-server$ sudo -E PATH="/usr/local/openresty/nginx/sbin:$PATH" venv/bin/5gms-application-server -c local-dev.conf
[2023-12-13 16:33:26 +0530] [88543] [INFO] Running on http://192.168.47.63:7777 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://192.168.47.63:7777 (CTRL + C to quit)
INFO:rt-5gms-as:Adding content hosting configuration ps1...
DEBUG:rt-5gms-as:provisioning_session_id = ps1, chc = ContentHostingConfiguration(name='Big Buck Bunny', ingest_configuration=IngestConfiguration(pull=True, protocol='urn:3gpp:5gms:content-protocol:http-pull-ingest', base_url=Url('https://ftp.itec.aau.at/datasets/DASHDataset2014/BigBuckBunny/4sec/')), distribution_configurations=[DistributionConfiguration(entry_point=None, content_preparation_template_id=None, canonical_domain_name='localhost', domain_name_alias=None, base_url=Url('http://localhost/m4d/provisioning-session-d54a1fcc-d411-4e32-807b-2c60dbaeaf5f/'), path_rewrite_rules=None, caching_configurations=None, geo_fencing=None, url_signature=None, certificate_id=None, supplementary_distribution_networks=None)])
[2023-12-13 16:33:33 +0530] [88543] [INFO] 192.168.13.27:58036 - - [13/Dec/2023:16:33:33 +0530] "POST /3gpp-m3/v1/content-hosting-configurations/ps1 1.1" 500 3383 "-" "5GMSdAF-nexus.naveen.local/testing"
[2023-12-13 16:33:33 +0530] [88543] [INFO] 192.168.13.27:58036 - - [13/Dec/2023:16:33:33 +0530] "POST /3gpp-m3/v1/content-hosting-configurations/ps1 1.1" - - "-" "5GMSdAF-nexus.naveen.local/testing"
[2023-12-13 16:33:33 +0530] [88543] [ERROR] Error in ASGI Framework
Traceback (most recent call last):
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/hypercorn/asyncio/task_group.py", line 27, in _handle
await app(scope, receive, send, sync_spawn, call_soon)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/hypercorn/app_wrappers.py", line 33, in call
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/applications.py", line 1106, in call
await super().call(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call
raise e
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/routing.py", line 274, in app
raw_response = await run_endpoint_function(
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/openapi_5g/apis/default_api.py", line 53, in create_content_hosting_configuration
await rt_5gms_as_svr_ifc.create_content_hosting_configuration(provisioningSessionId,content_hosting_configuration, request=request)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/server.py", line 66, in create_content_hosting_configuration
self.__context.addContentHostingConfiguration(provisioningSessionId, content_hosting_configuration)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 202, in addContentHostingConfiguration
self.__addContentHostingConfiguration(provisioning_session_id, content_hosting_configuration, force=True)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 351, in __addContentHostingConfiguration
chc_hash = self.__hashOpenAPIObject(chc)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 512, in __hashOpenAPIObject
return hash(obj.json(sort_keys=True))
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/typing_extensions.py", line 2499, in wrapper
return arg(*args, **kwargs)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/pydantic/main.py", line 1011, in json
raise TypeError('dumps_kwargs keyword arguments are no longer supported.')
TypeError: dumps_kwargs keyword arguments are no longer supported.
ERROR:hypercorn.error:Error in ASGI Framework
Traceback (most recent call last):
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/hypercorn/asyncio/task_group.py", line 27, in _handle
await app(scope, receive, send, sync_spawn, call_soon)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/hypercorn/app_wrappers.py", line 33, in call
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/applications.py", line 1106, in call
await super().call(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call
raise e
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/routing.py", line 274, in app
raw_response = await run_endpoint_function(
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/openapi_5g/apis/default_api.py", line 53, in create_content_hosting_configuration
await rt_5gms_as_svr_ifc.create_content_hosting_configuration(provisioningSessionId,content_hosting_configuration, request=request)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/server.py", line 66, in create_content_hosting_configuration
self.__context.addContentHostingConfiguration(provisioningSessionId, content_hosting_configuration)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 202, in addContentHostingConfiguration
self.__addContentHostingConfiguration(provisioning_session_id, content_hosting_configuration, force=True)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 351, in __addContentHostingConfiguration
chc_hash = self.__hashOpenAPIObject(chc)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/rt_5gms_as/context.py", line 512, in __hashOpenAPIObject
return hash(obj.json(sort_keys=True))
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/typing_extensions.py", line 2499, in wrapper
return arg(*args, **kwargs)
File "/home/naveen/b/rt-5gms-application-server/venv/lib/python3.8/site-packages/pydantic/main.py", line 1011, in json
raise TypeError('dumps_kwargs keyword arguments are no longer supported.')
TypeError: dumps_kwargs keyword arguments are no longer supported.

@m3682029:/b/rt-5gms-application-server$ tests/m3_client_cli.py -H 192.168.47.63:7777 add ps1 tests/examples/ContentHostingConfiguration_Big-Buck-Bunny_pull-ingest.json
There was a problem with the server: [500] Internal Server Error@m3682029:
/b/rt-5gms-application-server$

Desktop (please complete the following information):

  • OS:ubuntu 20.04
@davidjwbbc davidjwbbc self-assigned this Dec 13, 2023
@davidjwbbc davidjwbbc added the bug Something isn't working label Dec 13, 2023
@davidjwbbc
Copy link
Contributor

A change in the latest pydantic means that it no longer takes json.dumps() keyword parameters for its BaseObject.json() method.

The recommended solution is, instead of obj.json(sort_keys=True), to do json.dumps(obj.model_dump(), sort_keys=True)

But this only works with pydantic v2. I'll work out a way of doing the JSON conversion with both versions of pydantic (probably some auto detection of features on start up and dynamic function definition based on the features).

@dsilhavy
Copy link
Contributor

This issue causes an infinite loop when running the `msaf-configuration' tool. The AF will print the following error in a loop:

12/15 09:13:26.196: [msaf] ERROR: Internal server error
 (../src/5gmsaf/msaf-m1-sm.c:1891)
12/15 09:13:26.227: [msaf] ERROR: Internal server error
 (../src/5gmsaf/msaf-m1-sm.c:1891)

@davidjwbbc
Copy link
Contributor

Fixed in PR #82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants