openclimatefix / pv-site-api

Site specific API for PV forecasting
5 stars 8 forks source link

timezone aware method #167

Open aryanbhosale opened 2 months ago

aryanbhosale commented 2 months ago

Pull Request

Description

the datetime.utcnow() method is considered deprecated in modern Python versions, and it's recommended to use the more explicit datetime.now(tz=datetime.timezone.utc) instead. The utcnow() method is still functional, but it's considered less clear and less timezone-aware than the alternative. I have thus replaced the deprecated method with the newer one

Fixes #

Replaces the deprecated method with the newer one

Checklist:

aryanbhosale commented 2 months ago

Hi @peterdudfield could you please review this?

aryanbhosale commented 2 months ago

I will run make lint here, I accidentally deleted my dist-packages from wsl while installing poetry now I have to reinstall the entire thing :/ Will do it by tomorrow

peterdudfield commented 2 months ago

One test failed, you might just need to add a timezone to that line. Can you see where it failed in the CI?

aryanbhosale commented 2 months ago

One test failed, you might just need to add a timezone to that line. Can you see where it failed in the CI?

This happened because one_dat_from_now is a timezone aware object and the forecast_value.target_datetime_utc is timezone naive, i tried making the latter a timezone aware object too

peterdudfield commented 2 months ago

Unfortauntely the line just edited is now > 100, could you format this, and then hopefull it works

aryanbhosale commented 2 months ago

Unfortauntely the line just edited is now > 100, could you format this, and then hopefull it works

Done

aryanbhosale commented 2 months ago

Unfortauntely the line just edited is now > 100, could you format this, and then hopefull it works

Done

@peterdudfield let me try this locally first, currently I can't test because my linux is broken and I can't install poetry, but once I'm done I'll test it and we can test here

peterdudfield commented 2 months ago

Another lint error, I would recommend running make format before a commit to make sure these don't happen. Or run blacks with line 100, and isort

Sorry if these are over strict

aryanbhosale commented 2 months ago

Another lint error, I would recommend running make format before a commit to make sure these don't happen. Or run blacks with line 100, and isort

Sorry if these are over strict

Yes I'll make sure to do that, this time I couldn't because of my os issue, I'm trying to fix that before making another commit Thank you for the review

peterdudfield commented 2 months ago

Another lint error, I would recommend running make format before a commit to make sure these don't happen. Or run blacks with line 100, and isort Sorry if these are over strict

Yes I'll make sure to do that, this time I couldn't because of my os issue, I'm trying to fix that before making another commit Thank you for the review

Thanks, and thanks for you work on this