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

Update and refactor examples #237

Open
3 of 8 tasks
Maghnie opened this issue Feb 1, 2024 · 1 comment · May be fixed by #278
Open
3 of 8 tasks

Update and refactor examples #237

Maghnie opened this issue Feb 1, 2024 · 1 comment · May be fixed by #278
Assignees
Labels
documentation enhancement New feature or request good first issue Good for newcomers

Comments

@Maghnie
Copy link
Contributor

Maghnie commented Feb 1, 2024

Is your feature request related to a problem? Please describe.
Most of the examples haven't been updated since 2022, so now there's some deprecated code.

Describe the solution you'd like
Rerun the examples and update any code as necessary.

Additional context
Along the way, typos may be fixed, and examples may be clarified.

  • basic examples
    • refactor
    • fix pydantic bug
  • ngsi_v2
    • refactor
    • fix simple_ql bug

Nice-to-haves

  • Use colored logs
  • Add descriptions to the log messages as well (in addition to those in the comments)
@Maghnie Maghnie added enhancement New feature or request documentation labels Feb 1, 2024
@Maghnie
Copy link
Contributor Author

Maghnie commented Feb 1, 2024

Bug encountered in e02_ngsi_v2_context_relationships.py:

2024-02-01 17:54:24,333 __main__ INFO: [NamedContextAttribute(name='refStore', type='Relationship', value='urn:ngsi-ld:Store:001', metadata={}), NamedContextAttribute(name='refProduct', type='Relationship', value='urn:ngsi-ld:Product:001', metadata={})]
2024-02-01 17:54:24,341 __main__ INFO: [ContextEntity(id='urn:ngsi-ld:InventoryItem:001', type='InventoryItem', refProduct=ContextAttribute(type='Relationship', value='urn:ngsi-ld:Product:001', metadata={}), 
refStore=ContextAttribute(type='Relationship', value='urn:ngsi-ld:Store:001', metadata={}), stockCount=ContextAttribute(type='Integer', value=10000, metadata={}))]
refProduct==urn:ngsi-ld:Product:001
Traceback (most recent call last):
  File "d:\Repos\04-OpenSource\FiLiP\examples\ngsi_v2\e02_ngsi_v2_context_relationships.py", line 176, in <module>
    cb_client.get_entity_list(q="refStore!=urn:ngsi-ld:Store:002"))
  File "C:\Users\mmg\AppData\Local\anaconda3\envs\filip\lib\site-packages\filip\clients\ngsi_v2\cb.py", line 366, in get_entity_list
    q = QueryString.parse_str(q)
  File "C:\Users\mmg\AppData\Local\anaconda3\envs\filip\lib\site-packages\filip\utils\simple_ql.py", line 307, in parse_str
    return QueryString(qs=qs)
  File "C:\Users\mmg\AppData\Local\anaconda3\envs\filip\lib\site-packages\filip\utils\simple_ql.py", line 213, in __init__
    qs = self.__check_arguments(qs=qs)
  File "C:\Users\mmg\AppData\Local\anaconda3\envs\filip\lib\site-packages\filip\utils\simple_ql.py", line 230, in __check_arguments
    qs[idx] = QueryStatement(*item)
TypeError: filip.utils.simple_ql.QueryStatement() argument after * must be an iterable, not NoneType

caused by using string queries: cb_client.get_entity_list(q="refProduct==urn:ngsi-ld:Product:001")

but this works:

query = QueryString(qs=[('refProduct', '==', 'urn:ngsi-ld:Product:001')])
logger.info(cb_client.get_entity_list(q=query))

and used for now as a workaround.

A more long-term fix should probably be in this function:

def parse_str(cls, string: str):

@Maghnie Maghnie added the good first issue Good for newcomers label Feb 19, 2024
@WaltherTrgovac WaltherTrgovac self-assigned this Apr 17, 2024
@RWTH-EBC RWTH-EBC deleted a comment from github-actions bot Apr 23, 2024
@WaltherTrgovac WaltherTrgovac linked a pull request Apr 30, 2024 that will close this issue
@WaltherTrgovac WaltherTrgovac linked a pull request Apr 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants