-
Notifications
You must be signed in to change notification settings - Fork 13
Adapter for CKAN #214
Adapter for CKAN #214
Conversation
|
||
@property | ||
def resources(self) -> list[dict]: | ||
return self.data["resources"] |
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.
Map Resources here, and remove that logic from adapter.py
Same time you can use cachedproperty
it that property used several times
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.
Done
f"Error during getting data from workspace {self.__host}: {e}" | ||
) from e | ||
|
||
async def get_organizations(self) -> list[str]: |
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.
Could it be better to fetch organization details here and return list of Organization
?
You can use here gather
to fetch information concurrently, because now in adapter.py
in for loop you do it in sequential way.
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.
Done
async def get_organizations(self) -> list[str]: | ||
url = "/api/action/organization_list" | ||
resp = await self._get_request(url) | ||
if resp and resp["success"]: |
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.
You can dry that expression, because it used below many times in the same way
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.
And may be add some logic if response was failed
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.
I have created the method is_response_successful and moved this check to the _get_request
method. In case of failure, it will raise DataSourceError
. Only for _post_request
, this isn't added because not all files have structure included in CKAN, and in case of failure, we just want to return an empty list.
Closed #205 |
No description provided.