Skip to content

fix many deprecation warnings#365

Merged
dionhaefner merged 1 commit intoDHI:mainfrom
jkittner:deprecation-warnings-fix
Apr 17, 2025
Merged

fix many deprecation warnings#365
dionhaefner merged 1 commit intoDHI:mainfrom
jkittner:deprecation-warnings-fix

Conversation

@jkittner
Copy link
Contributor

the warnings came mainly from marshmallow and cpython itself

  • you cannot provide metadata via kwargs to scheams in marshmallow any longer
  • validator must not return bools any longer - just raise an exception upon failure
  • some minor cpython stuff e.g. in the ast module

In total that should have removed a couple hundred warnings - and I enabled them again, so we can actually see if something is deprecated.

There is a warning left with multiprocessing I cannot find the root cause of.

mainly from marshmallow and cpython itself
@jkittner jkittner force-pushed the deprecation-warnings-fix branch 2 times, most recently from 055ca3e to 6d03979 Compare April 16, 2025 16:01
@jkittner
Copy link
Contributor Author

I restored the ignores to the previous state:

we had 378 warnings on 3.12 before this patch. We are now down to 224 and with #364 we will be down to 216.

What remains are these warnings:

tests/drivers/test_raster_drivers.py: 14 warnings
tests/scripts/test_optimize_rasters.py: 182 warnings
tests/server/test_cors.py: 3 warnings
  /usr/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=152991) is multi-threaded, use of fork() may lead to deadlocks in the child.
    self.pid = os.fork()

tests/drivers/test_sqlite_remote.py: 17 warnings
  /home/kittnjdr/workspace/terracotta/.tox/py312/lib/python3.12/site-packages/botocore/auth.py:425: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    datetime_now = datetime.datetime.utcnow()

The boto one is clearly not our fault and needs fixing upstream - the former ones likely are and I believe are due to ThreadPoolExecutor?

@dionhaefner
Copy link
Collaborator

As long as tests are passing I'm not too worried about deprecation warnings. The majority of them will be fixed by other people (3rd party maintainers) when they become a problem. For the remainder, we'll deal with them when they actually break something; at that point there are usually enough guides on how to update that this transition is much easier to deal with.

@dionhaefner
Copy link
Collaborator

So yes, the former is likely a consequence of the fact that we use a ProcessPoolExecutor in code that is multithreaded, but when the time comes and this actually gets deprecated there will likely be an official alternative to use (that e.g. avoids using fork under the hood).

Copy link
Collaborator

@dionhaefner dionhaefner left a comment

Choose a reason for hiding this comment

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

Good fixes, thanks for the cleanup!

@dionhaefner dionhaefner merged commit 90636e7 into DHI:main Apr 17, 2025
7 checks passed
@jkittner jkittner deleted the deprecation-warnings-fix branch April 17, 2025 10:51
@jkittner
Copy link
Contributor Author

btw. marshmallow 4.0.0 release 10 hours ago (https://pypi.org/project/marshmallow/4.0.0/) so version 0.9.0 currently does not install cleanly w/o specifying marshmallow<4.0.0. This patch/the main branch should have already fixed that.

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.

2 participants