Skip to content

Commit

Permalink
Add test to make sure we don't import aiohttp
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Dec 13, 2024
1 parent 898cafa commit 60155af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/slow_dependencies_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright Modal Labs 2024
import subprocess
import sys


def test_slow_dependencies_local(supports_dir):
# Make sure that "import modal" doesn't load some big dependencies like aiohttp
subprocess.check_output([sys.executable, supports_dir / "slow_dependencies_local.py"])


def test_slow_dependencies_container(supports_dir):
# Make sure that "import modal._container_entrypoint" doesn't load some big dependencies like aiohttp
subprocess.check_output([sys.executable, supports_dir / "slow_dependencies_container.py"])
10 changes: 10 additions & 0 deletions test/supports/slow_dependencies_container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright Modal Labs 2024
import sys

import modal # noqa

assert "modal" in sys.modules

# This is a very heavy dependency that takes about 70-80ms to import
# Let's make sure it doesn't get imported in global scope
assert "aiohttp" not in sys.modules
10 changes: 10 additions & 0 deletions test/supports/slow_dependencies_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright Modal Labs 2024
import sys

import modal # noqa

assert "modal" in sys.modules

# This is a very heavy dependency that takes about 70-80ms to import
# Let's make sure it doesn't get imported in global scope
assert "aiohttp" not in sys.modules

0 comments on commit 60155af

Please sign in to comment.