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

Feature/point of interest structure upgrade #22

Conversation

moorchegue
Copy link
Collaborator

Addresses #21.

This is really a work in progress, but I'd like to share it early anyway, since it might help catch some gotchas early on as well.

@moorchegue moorchegue force-pushed the feature/point_of_interest_structure_upgrade branch from 721f8db to a93833e Compare June 7, 2022 04:49
@@ -19,12 +19,16 @@ def transform(self, source: List[SpreadsheetRow]) -> List[PointOfInterest]:
return [self.transform_row(row) for row in source]

def transform_row(self, row: SpreadsheetRow) -> PointOfInterest:
rename = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use existing ALIASES above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, exactly same purpose.

@@ -1,5 +1,8 @@
from typing import Set


DEFAULT_CATEGORY = 'Any help'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has already been added by @idisblueflash so your PR should not have this change, please, merge/rebase the latest master

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, bad double rebase…

country: str = ''
city: str = ''
address: str = ''
categories: List[str] = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure that these convert correctly into CSV and don't break existing unit tests for spiders

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tests I did fix, but export to CSV might actually work a bit differently. Let me poke around it a bit more…


log = logging.getLogger(__name__)


Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this file here? Are you combining 2 PRs in one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually thought that it was merged. Is it okay to merge it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, you can merge it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool, thanks!

@@ -79,8 +79,15 @@ def test_spreadsheet_data_conversion():

result = usecase.convert_spreadsheet("some-id")
csv = FILE_VALUES[0]
expected_row = "The Ukrainian House,Poland,Warsaw,\"ul. Zamenhofa 1, 00-153\",52.24734033,20.9964833," \
"Accommodation,Fundacja “Nasz Wybór”,Crisis support center"
expected_row = 'The Ukrainian House,Poland,Warsaw,' \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you using some auto-formatter that converts all quotes to single-quotes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, one style of quotes does make it a bit easier for me. Do we have a preference what quotes to use?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that one style is better, I don't have a preference but I was leaning towards double-quotes because is later we'll enable some auto-formatter like black it's going to force double-quotes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No problem, I'll go with that from now on then.

@moorchegue
Copy link
Collaborator Author

As I was fixing moldova_dopomoga crawler (probably source data changed), I noticed that there's also a map there (now): https://www.google.com/maps/d/embed?mid=1RiyRvxOE8q3Z-eo7e298nLn_I0nKXqq6&ehbc=2E312F&ll=47.152161219376964%2C28.378650750000023&z=8

It seems to have all the same info, and also coordinates for all the points. Would you like me to update the crawler to scrape that info?

@littlepea
Copy link
Collaborator

As I was fixing moldova_dopomoga crawler (probably source data changed), I noticed that there's also a map there (now): https://www.google.com/maps/d/embed?mid=1RiyRvxOE8q3Z-eo7e298nLn_I0nKXqq6&ehbc=2E312F&ll=47.152161219376964%2C28.378650750000023&z=8

It seems to have all the same info, and also coordinates for all the points. Would you like me to update the crawler to scrape that info?

It would be nice if it's easy to do 👍

@moorchegue
Copy link
Collaborator Author

Sure, no problem!

@moorchegue moorchegue force-pushed the feature/point_of_interest_structure_upgrade branch from dc4324a to d9e2b61 Compare June 7, 2022 06:50
@wdunn001
Copy link
Collaborator

wdunn001 commented Jun 9, 2022

Make sure to pull latest.

@moorchegue moorchegue force-pushed the feature/point_of_interest_structure_upgrade branch from 028e2c8 to 19fc0f0 Compare June 10, 2022 11:37
@moorchegue
Copy link
Collaborator Author

Hm… looks like poetry install fails on some package in the CI… Have anybody ran into this? I installed locally into a venv with pip install -e . , that worked.

Other than that I think I fixed all outstanding issues. Could you guys take a peek, please?

@littlepea
Copy link
Collaborator

Hm… looks like poetry install fails on some package in the CI… Have anybody ran into this? I installed locally into a venv with pip install -e . , that worked.

Other than that I think I fixed all outstanding issues. Could you guys take a peek, please?

On master branch CI is passing...

@wdunn001 any ideas?

email: str = ''
url: str = ''
socialmedia: str = ''
messenger: str = ''
Copy link
Collaborator

Choose a reason for hiding this comment

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

While you were working on it they've add two more fields to the schema 😂

messenger ->  FB messenger
telegram  -> telegram
whatsapp -> whatsapp

@wdunn001
Copy link
Collaborator

wdunn001 commented Jun 10, 2022

appears to be related to this python-poetry/poetry#728.

Seems there is an outage in PyPi judging from their status page. Probably not related to poetry.

https://status.python.org/

https://stackoverflow.com/questions/72551057/poetry-gives-toomanyindirects-error-suddenly

@wdunn001
Copy link
Collaborator

wdunn001 commented Jun 10, 2022

checked tests are working correctly now something in your latest PR is breaking tests.

email: str = ''
url: str = ''
socialmedia: str = ''
fb_messenger: str = ''
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of the fields should still be just messenger, "FB messenger" was the meaning



# XXX: there must be some that encodes/decodes this kind of structure
def parse_points(json_xml):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a dedicated unit test for this function so that we can see what kind of JSON you're parsing?

In theory, you could deserialize it into a pydantic model

@littlepea
Copy link
Collaborator

I'm gonna merge it so that we can have the new schema on master, we can address any remaining issues in a separate PR

@littlepea littlepea merged commit af0345e into safe-refuge:master Jun 11, 2022
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.

3 participants