Skip to content

add: world_clock.py and test_world_clock.py#222

Open
nir9696 wants to merge 17 commits intoPythonFreeCourse:developfrom
nir9696:feature/world_clock
Open

add: world_clock.py and test_world_clock.py#222
nir9696 wants to merge 17 commits intoPythonFreeCourse:developfrom
nir9696:feature/world_clock

Conversation

@nir9696
Copy link
Contributor

@nir9696 nir9696 commented Feb 6, 2021

No description provided.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

That's a good start! let's have the first improvement cycle :)

Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't manage our own database of timezones. Please use pytz.all_timezones or something familiar :)

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 have looked into several modules in Python, including pytz, and I can not see how they help here. I have invested a lot of time and energy in writing a code that supports large amount(!) of cities and places and not just the "timezone places" themselves.
the "Mini DB" I've created is not just a list of timezones - it maps timezones to countries and subcountries and crucial for the core of my code - Ability to search the equivalent time of a custom city or place.

@nir9696 nir9696 requested a review from yammesicka February 12, 2021 09:33
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Added few more comments :)

@nir9696
Copy link
Contributor Author

nir9696 commented Feb 15, 2021

Hi :)
Can you please response to the 2 comments I wrote above?

@nir9696 nir9696 requested a review from yammesicka February 15, 2021 21:10
@codecov-io
Copy link

codecov-io commented Feb 16, 2021

Codecov Report

Merging #222 (4273a6c) into develop (b5f0545) will decrease coverage by 3.83%.
The diff coverage is 94.11%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #222      +/-   ##
===========================================
- Coverage    99.38%   95.54%   -3.84%     
===========================================
  Files           37       80      +43     
  Lines         1456     3727    +2271     
===========================================
+ Hits          1447     3561    +2114     
- Misses           9      166     +157     
Impacted Files Coverage Δ
app/database/alembic/env.py 0.00% <0.00%> (ø)
app/internal/audio.py 28.94% <28.94%> (ø)
app/routers/audio.py 43.90% <43.90%> (ø)
app/routers/user.py 80.00% <68.42%> (-20.00%) ⬇️
app/routers/profile.py 92.79% <74.19%> (-7.21%) ⬇️
app/routers/weight.py 81.57% <81.57%> (ø)
app/routers/credits.py 85.71% <85.71%> (ø)
app/routers/four_o_four.py 85.71% <85.71%> (ø)
app/utils/extending_openapi.py 88.88% <88.88%> (ø)
app/internal/on_this_day_events.py 90.62% <90.62%> (ø)
... and 113 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5f0545...7953228. Read the comment docs.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Hi, I've added further insights.

@nir9696 nir9696 requested a review from yammesicka February 18, 2021 18:34
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Great start, just few things before we can merge it

@nir9696 nir9696 requested a review from yammesicka February 23, 2021 18:42
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Great job, please take a look at the insights :)

return city_element[SUBCOUNTRY_NAME_KEY_IN_CITIES]


async def get_api_data(url: str) -> Optional[List[Any]]:
Copy link
Member

Choose a reason for hiding this comment

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

Cache this function to prevent high loading times

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 did my best to do so by using the decorator @functools.lru_cache but I always get runtime errors with the message: "cannot reuse already awaited coroutine". The truth is I'm pretty desperate and do not know how to solve this. I probably won't have the time to work on the code again by the end of the submission deadline - Can you consider giving up this matter or help me here? I have worked so hard...

Copy link
Member

Choose a reason for hiding this comment

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

Have you tried async-lru?

Comment on lines 414 to 416
Copy link
Member

Choose a reason for hiding this comment

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

Use git precommit hooks to fix this formatting

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 don't see it. this note has already been resolved and I see the correct formmating without the \ char.
This note is also "Outdated". Can you check again? :)

@nir9696 nir9696 requested a review from yammesicka February 23, 2021 22:06
Copy link
Contributor

Choose a reason for hiding this comment

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

Keys should be lowercase, reformat in a human readable way.
Also, is there really no python module that does this? I find this very very unlikely...

return city_element[SUBCOUNTRY_NAME_KEY_IN_CITIES]


async def get_api_data(url: str) -> Optional[List[Any]]:
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried async-lru?

return continent_name


def load_country_continent_data_set() -> List[Dict[str, str]]:
Copy link
Member

Choose a reason for hiding this comment

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

Cache the return value, reading and parsing JSON every time is expensive

)


def load_city_country_data_set() -> List[Dict[str, str]]:
Copy link
Member

Choose a reason for hiding this comment

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

Cache the return value, reading and parsing JSON every time is expensive

return f"{TIMEZONES_BASE_URL}/{timezone}"


def load_country_subcountry_data_set() -> List[Dict[str, str]]:
Copy link
Member

Choose a reason for hiding this comment

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

Cache this

@nir9696
Copy link
Contributor Author

nir9696 commented Feb 24, 2021

  1. I tried to use both async-lru, for the asynchronous function, and functools.lru_cache, for uploading the files,
    and many tests fail suddenly for RuntimeError: Event loop is closed
    and 174 Http Error errors.
    I tried everything and I am lost.
  2. Also, my code is after the prehook fixes, so I do not know what I have left to fix ...

@nir9696 nir9696 requested a review from yammesicka February 24, 2021 17:40
@yammesicka
Copy link
Member

There are few comments that aren't related to caching. Fix them and I'll consider this as a ticket :)

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.

4 participants

Comments