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

221 ngsi ld migrate v2 datamodels in ld #234

Conversation

djs0109
Copy link
Contributor

@djs0109 djs0109 commented Jan 23, 2024

close #221 #220

@djs0109 djs0109 linked an issue Jan 23, 2024 that may be closed by this pull request
@djs0109 djs0109 changed the base branch from master to NGSI-LD February 20, 2024 13:59
Copy link
Contributor

@Maghnie Maghnie left a comment

Choose a reason for hiding this comment

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

Very cool addition!

Some general questions for my understanding:

  • Why is it necessary to have distinct named and unnamed versions? E.g. NamedContextProperty and ContextProperty. I would assume that a named version is preferable and that a name would be created by default, if not given by the user.
  • This is not limited to the LD branch in filip, but is the prefix "Context" necessary? E.g. couldn't we just say NamedProperty or Property, since a context is anyway implied when we use fiware?

Returns:

"""
return q
Copy link
Contributor

Choose a reason for hiding this comment

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

Add validation code?

Comment on lines 93 to 96
if value == "Relationship":
value == "Relationship"
elif value == "TemporalProperty":
value == "TemporalProperty"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why no warning and reassignment of value here?

elif value == "TemporalProperty":
value == "TemporalProperty"
else:
logging.warning(msg='NGSI_LD Properties must have type "Property"')
Copy link
Contributor

Choose a reason for hiding this comment

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

Also mention in the message that the type will be forcibly set as "Property"?

elif value == "TemporalProperty":
value == "TemporalProperty"
else:
logging.warning(msg='NGSI_LD GeoProperties must have type "GeoProperty" '
Copy link
Contributor

Choose a reason for hiding this comment

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

What scenario would cause this check to be executed even if no GeoProperties were used?

In the NGSI-LD data model, properties have a name, the type "Geoproperty" and a value.
"""
name: str = Field(
titel="Property name",
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
titel="Property name",
titel="GeoProperty name",

return value


class ContextGeoProperty(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

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

How come ContextGeoProperty doesn't inherit from ContextProperty?

Comment on lines 596 to 601
def add_attributes(self, **kwargs):
"""
Invalid in NGSI-LD
"""
raise NotImplementedError(
"This method should not be used in NGSI-LD")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice idea to add this for users coming from ngsi-v2!

Maybe also add a hint, so something like "This method should not be used in NGSI-LD. Try using add_properties instead."

Comment on lines 201 to 247
def test_entity_delete_attributes(self):
"""
Test the delete_attributes methode
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to ..._delete_properties?

Comment on lines 163 to 168
example3_temporalQ = {
"timerel": "between",
"timeAt": "2017-12-13T14:20:00Z"
}
with self.assertRaises(ValueError):
TemporalQuery.model_validate(example3_temporalQ)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good defensive testing!

update the get_context method in order to respect entitites without context
@djs0109 djs0109 changed the base branch from NGSI-LD to 212-testcase-for-every-endpoint-1 September 17, 2024 09:51
@djs0109 djs0109 merged commit 47ac79a into 212-testcase-for-every-endpoint-1 Sep 17, 2024
1 check failed
@djs0109
Copy link
Contributor Author

djs0109 commented Sep 17, 2024

The data models have been mostly implemented. The fine-tuning will be done together with the endpoints. To this end, this PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate NGSI-V2 datamodels for NGSI-LD integration
3 participants