Skip to content

Conversation

@yaugenst-flex
Copy link
Collaborator

@yaugenst-flex yaugenst-flex commented Nov 3, 2025

Greptile Overview

Updated On: 2025-11-03 08:54:39 UTC

Greptile Summary

This PR restores backward compatibility for legacy environment exports from tidy3d.web.core.environment. Users who previously accessed environment instances like dev, uat, prod, pre, and nexus directly from this module will now have those exports available again, with appropriate deprecation warnings pointing them to the new config system.

Key changes:

  • Added module-level __getattr__ and __dir__ to tidy3d.web.core.environment to dynamically provide legacy environment instances
  • All legacy access now emits DeprecationWarning with clear migration path to tidy3d.config.Env.{name} or tidy3d.config.config.switch_profile(...)
  • Added comprehensive test coverage verifying the legacy exports work correctly and emit proper deprecation warnings
  • Added TODO comments throughout documenting the deprecation timeline (removal planned for Tidy3D 2.12)
  • Made web.core.environment submodule explicitly available via tidy3d.web.core.__init__.py

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward backward compatibility shims that restore previously available functionality. The implementation uses standard Python module-level __getattr__ patterns, includes proper deprecation warnings, has comprehensive test coverage, and doesn't modify any core logic. All changes are additive and well-documented with clear deprecation timelines.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
tidy3d/web/core/environment.py 5/5 Added __getattr__ and __dir__ to dynamically export legacy environment instances (dev, uat, etc.) with deprecation warnings
tidy3d/web/core/init.py 5/5 Added environment submodule import to expose legacy environment exports
tests/config/test_legacy_env.py 5/5 Added comprehensive test verifying legacy environment exports work with proper deprecation warnings

Sequence Diagram

sequenceDiagram
    participant User
    participant web.core.environment
    participant __getattr__
    participant tidy3d.config.Env
    participant LegacyEnvironment
    participant warnings

    User->>web.core.environment: import tidy3d.web.core.environment
    Note over web.core.environment: Module loads with Env, Environment, EnvironmentConfig
    
    User->>web.core.environment: access environment.dev
    web.core.environment->>__getattr__: __getattr__("dev")
    __getattr__->>__getattr__: check if "dev" in _LEGACY_ENV_NAMES
    __getattr__->>warnings: warn deprecation message
    __getattr__->>tidy3d.config.Env: getattr(Env, "dev")
    tidy3d.config.Env->>LegacyEnvironment: __getattr__("dev")
    LegacyEnvironment-->>tidy3d.config.Env: return LegacyEnvironmentConfig("dev")
    tidy3d.config.Env-->>__getattr__: return dev config
    __getattr__-->>User: return dev environment config

    User->>web.core.environment: access environment.uat
    web.core.environment->>__getattr__: __getattr__("uat")
    __getattr__->>warnings: warn deprecation message
    __getattr__->>tidy3d.config.Env: getattr(Env, "uat")
    tidy3d.config.Env->>LegacyEnvironment: __getattr__("uat")
    LegacyEnvironment-->>User: return uat environment config
Loading

@yaugenst-flex yaugenst-flex self-assigned this Nov 3, 2025
@yaugenst-flex yaugenst-flex added the rc3 3rd pre-release label Nov 3, 2025
Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

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

Thanks, it was a bit annoying to have to run in two different ways when I'm testing something between different versions.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

6 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@yaugenst-flex yaugenst-flex added this pull request to the merge queue Nov 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/web/core/init.py (100%)
  • tidy3d/web/core/environment.py (92.9%): Missing lines 42

Summary

  • Total: 17 lines
  • Missing: 1 line
  • Coverage: 94%

tidy3d/web/core/environment.py

Lines 38-43

  38     raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
  39 
  40 
  41 def __dir__() -> list[str]:
! 42     return sorted(set(__all__))

Merged via the queue into develop with commit ba352a5 Nov 3, 2025
67 of 69 checks passed
@yaugenst-flex yaugenst-flex deleted the FXC-3944-restore-legacy-tidy-3-d-web-core-environment-exports-after-config-refactor branch November 3, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rc3 3rd pre-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants