Skip to content

Commit dc3eb7e

Browse files
FXC-4741-move-core-modules-to-common-submodule
1 parent db8dbc3 commit dc3eb7e

178 files changed

Lines changed: 29328 additions & 28714 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
[submodule "docs/notebooks"]
2-
path = docs/notebooks
3-
url = git@github.com:flexcompute/tidy3d-notebooks.git
4-
[submodule "docs/faq"]
5-
path = docs/faq
6-
url = https://github.com/flexcompute/tidy3d-faq

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
- Added deprecation warning for ``TemperatureMonitor`` and ``SteadyPotentialMonitor`` when ``unstructured`` parameter is not explicitly set. The default value of ``unstructured`` will change from ``False`` to ``True`` after the 2.11 release.
3737
- Added validation to `GaussianDoping` to ensure `ref_con < concentration`, validate `source` face identifier, and warn the user when the box size is not sufficient for the specified transition width.
3838
- Local caching is now enabled by default (set `td.config.local_cache.enabled=False` to opt out).
39+
- Reduced computation time of `adaptive_vjp_spacing` for `GeometryGroup` by allowing permittivity based spacing value to be cached.
3940

4041
### Fixed
4142
- Fixed intermittent "API key not found" errors in parallel job launches by making configuration directory detection race-safe.
@@ -45,6 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4546
- Fixed `CustomMedium` gradient calculation when field coordinates exactly align with boundaries.
4647
- Fixed adjoint simulation `grid_spec` to align exactly with forward simulation for correct `FieldData` adjoint source power.
4748
- Fixed redundant logging when `Batch.download()` skips existing files, and added `replace_existing` to `Batch.run()` so overwrite behavior can be controlled directly.
49+
- Fixed redundant server lookups when loading simulation results.
50+
- Updated docstrings for `DerivativeInfo` to more accurately reflect dataclass fields.
4851

4952
## [2.10.2] - 2026-01-21
5053

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
"""Ensure tidy3d._common modules avoid importing from tidy3d outside tidy3d._common."""
2+
3+
from __future__ import annotations
4+
5+
import argparse
6+
import ast
7+
import sys
8+
from collections.abc import Iterable
9+
from dataclasses import dataclass
10+
from pathlib import Path
11+
12+
13+
@dataclass(frozen=True)
14+
class ImportViolation:
15+
file: str
16+
line: int
17+
statement: str
18+
19+
20+
def parse_args(argv: Iterable[str]) -> argparse.Namespace:
21+
parser = argparse.ArgumentParser(
22+
description=(
23+
"Ensure tidy3d._common does not import from tidy3d modules outside tidy3d._common."
24+
)
25+
)
26+
parser.add_argument(
27+
"--root",
28+
default="tidy3d/_common",
29+
help="Root directory to scan (relative to repo root).",
30+
)
31+
return parser.parse_args(argv)
32+
33+
34+
def main(argv: Iterable[str]) -> None:
35+
args = parse_args(argv)
36+
repo_root = Path.cwd().resolve()
37+
root = (repo_root / args.root).resolve()
38+
if not root.exists():
39+
print(f"No directory found at {root}. Skipping check.")
40+
return
41+
42+
violations: list[ImportViolation] = []
43+
for path in sorted(root.rglob("*.py")):
44+
violations.extend(_violations_in_file(path, repo_root))
45+
46+
if violations:
47+
print("Invalid tidy3d imports found in tidy3d._common:")
48+
for violation in violations:
49+
print(f"{violation.file}:{violation.line}: {violation.statement}")
50+
raise SystemExit(1)
51+
52+
print("No invalid tidy3d imports found in tidy3d._common.")
53+
54+
55+
def _violations_in_file(path: Path, repo_root: Path) -> list[ImportViolation]:
56+
source = path.read_text(encoding="utf-8")
57+
try:
58+
tree = ast.parse(source)
59+
except SyntaxError as exc:
60+
raise SystemExit(f"Syntax error parsing {path}: {exc}") from exc
61+
62+
rel_path = str(path.relative_to(repo_root))
63+
violations: list[ImportViolation] = []
64+
for node in ast.walk(tree):
65+
if isinstance(node, ast.Import):
66+
for alias in node.names:
67+
name = alias.name
68+
if name == "tidy3d" or (
69+
name.startswith("tidy3d.") and not name.startswith("tidy3d._common")
70+
):
71+
violations.append(
72+
ImportViolation(
73+
file=rel_path,
74+
line=node.lineno,
75+
statement=_statement(source, node),
76+
)
77+
)
78+
elif isinstance(node, ast.ImportFrom):
79+
if node.level:
80+
continue
81+
module = node.module
82+
if not module:
83+
continue
84+
if module == "tidy3d":
85+
for alias in node.names:
86+
if alias.name != "_common":
87+
violations.append(
88+
ImportViolation(
89+
file=rel_path,
90+
line=node.lineno,
91+
statement=_statement(source, node),
92+
)
93+
)
94+
continue
95+
if module.startswith("tidy3d.") and not module.startswith("tidy3d._common"):
96+
violations.append(
97+
ImportViolation(
98+
file=rel_path,
99+
line=node.lineno,
100+
statement=_statement(source, node),
101+
)
102+
)
103+
return violations
104+
105+
106+
def _statement(source: str, node: ast.AST) -> str:
107+
segment = ast.get_source_segment(source, node)
108+
if segment:
109+
return " ".join(segment.strip().splitlines())
110+
return node.__class__.__name__
111+
112+
113+
if __name__ == "__main__":
114+
main(sys.argv[1:])

tests/config/test_legacy_env.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ def test_env_vars_follow_profile_switch(
9393

9494
def test_web_core_environment_reexports():
9595
"""Legacy `tidy3d.web.core.environment` exports remain available via config shim."""
96-
97-
import tidy3d.web as web
96+
from tidy3d._common.web.core import environment
9897
from tidy3d.config import Env as ConfigEnv
9998

100-
environment = web.core.environment
10199
assert environment.Env is ConfigEnv
102100

103101
with warnings.catch_warnings(record=True) as caught:

tests/config/test_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from click.testing import CliRunner
77
from pydantic import Field
88

9+
from tidy3d._common.config import loader as config_loader # import from common as it is patched
910
from tidy3d.config import get_manager, reload_config
10-
from tidy3d.config import loader as config_loader
1111
from tidy3d.config import registry as config_registry
1212
from tidy3d.config.legacy import finalize_legacy_migration
1313
from tidy3d.config.loader import migrate_legacy_config

0 commit comments

Comments
 (0)