Skip to content

Conversation

@DomThePorcupine
Copy link
Contributor

I missed that someone else already had a PR open for this :( but I did manage to get all the tests passing with minimal changes, so I'm opening this in case it's helpful :)

Copy link
Contributor

@maxkahan maxkahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is a great contribution and I would say almost there in terms of merging and releasing this. There are some issues that hold it back a little though, that we'd need to fix to get it over the line.

  • There are quite a few warnings about the validate decorator (from v1) and various objects (including smart_union) that have also been deprecated/are discouraged.
  • Methods like parse_obj, dict etc. are deprecated as well.
  • Class-based config is deprecated so this is throwing a warning.
  • There seems to be a couple of issues with serialization.
  • Finally, you don't need to use the Optional type to show optional model arguments any more, Pydantic infers this now. Not a big deal though, this one isn't a must-fix, just makes the code tidier.

The warnings are coming through to test scripts showing real SDK use cases, so they do need to go really before we can release this, but this is a great start that manages to get quite a lot of the way there!

In terms of getting to a release, I think it's just a bit of swapping more old syntax for new v2 syntax and changing a couple of model fields around.

@maxkahan maxkahan mentioned this pull request Dec 22, 2023
@DomThePorcupine
Copy link
Contributor Author

My apologies I was running make test which disables the warnings :(

I was able to go through and address all the pydantic deprecations. I think it's much better now!

  • remove validate decorator in favor of @field_validator
  • remove smart_union (it's the default now)
  • remove parse_obj and .dict() in favor of model_validate() and model_dump
  • fix odd serialization errors
  • remove Optional[]

Let me know if there's anything else you need

# nbs.get_pay_text_prompt(),
]
ncco = Ncco.build_ncco(actions=action_list)
assert ncco == nbs.insane_ncco
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we could get this one passing I think it's good!

@maxkahan
Copy link
Contributor

Hi @DomThePorcupine this is awesome, thanks for working on the changes so quickly. Just the one test you commented out that we should have back in, but everything else is looking great! 🙂

@DomThePorcupine
Copy link
Contributor Author

Whoops! That was embarrassing, thanks for catching that :)

@maxkahan maxkahan self-requested a review December 22, 2023 18:52
type = Field('sip', const=True)
type: Literal['sip'] = 'sip'
uri: str
headers: Optional[dict]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have had a final read through and it looks like this needs an = None to mark it optional, just removing the Optional type here has made it required. I think there may be more cases like this where removing the Optional type has made it a required field 😖

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: have consulted the pydantic docs and Optional has a specific meaning in this case. I think it's okay to swap it out for = None here though as when we serialize models we ignore None values anyway

uri: AnyUrl
contentType: Literal['audio/l16;rate=16000', 'audio/l16;rate=8000']
headers: Optional[dict]
headers: dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
headers: dict
headers: dict = None

class VoicePrompt(BaseModel):
language: Optional[str]
style: Optional[int]
language: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
language: str
language: str = None

language: Optional[str]
style: Optional[int]
language: str
style: int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
style: int
style: int = None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tabbed through - only found one other place where the None was missing

@maxkahan
Copy link
Contributor

Think I found all the parts that needed changing, but it's probably wise to double check


class PayPrompts:
class VoicePrompt(BaseModel):
language: Optional[str]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also caught one here

Copy link
Contributor

@maxkahan maxkahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we've worked out all the kinks! Thanks for your work on this PR, I'll merge it in and prepare for a new SDK release 😄

@maxkahan maxkahan merged commit 0a8d217 into Vonage:main Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants