
    ^j                     `   d Z ddlZddlZddlZddlZddlZddlZddlmZ 	 ddl	Z	dZ
e
r ee	d      s ee	dd      Zeee	_        ddlmZ dd	lmZ dd
lmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" g dZ#de$ejJ                  e$   z  dedefdZ& e'h d      Z( e'ddh      Z)dddZ* G d dejV                  jX                        Z- G d dejV                  j\                        Z/ e/       Z0 eedd      s#ejb                  je                  de0       de_3        de$fdZ4y# e$ r dZ
Y w xY w)u  RF-DETR public package initialiser.

Two-phase legacy-module deprecation
------------------------------------
Some sub-packages were relocated in v1.6.0 and are scheduled for removal in v1.9.0. The migration is handled in
two phases so users get a full release cycle to update their imports:

**Phase 1 — v1.7.0 (current):** the old packages (``rfdetr.util``, ``rfdetr.deploy``) still exist on disk and work
normally, but emit a ``DeprecationWarning`` on import. ``_RemovedModuleFinder`` is installed in ``sys.meta_path`` but
stays dormant: its ``find_spec`` returns ``None`` whenever ``importlib.machinery.PathFinder`` can resolve the name (i.e.
while the shim directories are present).

**Phase 2 — v1.9.0:** the shim directories are deleted.  ``PathFinder`` can no longer resolve ``rfdetr.util`` /
``rfdetr.deploy``, so ``_RemovedModuleFinder`` intercepts the import and raises a descriptive ``ImportError`` (migration
hint) instead of the cryptic default ``ModuleNotFoundError: No module named 'rfdetr.util'``.

To complete Phase 2, delete ``src/rfdetr/util/`` and ``src/rfdetr/deploy/`` and bump
``_REMOVE_IN_VERSION_1_9`` (or rename it) to reflect the new version boundary.
    N)AnyTFcomplex_
complex128)RFDETR)ModelContext)
RFDETRBaseRFDETRKeypointPreviewRFDETRLargeRFDETRLargeDeprecatedRFDETRMedium
RFDETRNanoRFDETRSeg2XLargeRFDETRSegLargeRFDETRSegMediumRFDETRSegNanoRFDETRSegPreviewRFDETRSegSmallRFDETRSegXLargeRFDETRSmall)r   from_checkpointr	   r   r   r   r
   r   r   r   r   r   r   pathkwargsreturnc                 .    t        j                  | fi |S )zYConvenience wrapper for RFDETR.from_checkpoint(); see that method for full documentation.)r   r   )r   r   s     Z/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/__init__.pyr   r   V   s    !!$1&11    >   build_trainerRFDETRDataModuleRFDETRModelModuleRFDETR2XLargeRFDETRXLargezDrfdetr.util will be removed in v1.9.0. Use rfdetr.utilities instead.zCrfdetr.deploy will be removed in v1.9.0. Use rfdetr.export instead.)utildeployc                   h    e Zd ZdZdeddfdZdej                  j                  ddfdZ	de
ddfd	Zy)
_RemovedModuleLoaderzHRaise a migration hint when a removed legacy module import is attempted.messager   Nc                     || _         y N)_message)selfr&   s     r   __init__z_RemovedModuleLoader.__init__j   s	    r   specc                      y)z%Use the default module creation path.N )r*   r,   s     r   create_modulez"_RemovedModuleLoader.create_modulem   s    r   modulec                 .    t        | j                        d)zGAbort import with a migration hint instead of bare ModuleNotFoundError.N)ImportErrorr)   )r*   r0   s     r   exec_modulez _RemovedModuleLoader.exec_moduleq   s    $--(d2r   )__name__
__module____qualname____doc__strr+   	importlib	machinery
ModuleSpecr/   objectr3   r.   r   r   r%   r%   g   sJ    R     )"5"5"@"@ T 3& 3T 3r   r%   c            
           e Zd ZdZej
                  j                  Z	 ddede	e   dz  de
dz  dej
                  j                  dz  fdZy)	_RemovedModuleFinderzNIntercept removed legacy dotted imports after their shim packages are deleted.Nfullnamer   targetr   c                 Z   |j                  t         d      sy|j                  t         d      j                  d      \  }}}|t        vry| j
                  j                  ||      y|t         d| k(  }t        t        |         }t        j                  j                  |||      S )zGReturn a failing spec with a migration hint for removed legacy modules..N)
is_package)
startswithr4   removeprefix	partition_REMOVE_IN_VERSION_1_9_PATH_FINDER	find_specr%   r9   r"   spec_from_loader)r*   r?   r   r@   root_rC   loaders           r   rI   z_RemovedModuleFinder.find_spec{   s     ""hZq>2**hZq>:DDSI
a--&&x6BH:Qtf!55
%&<T&BC~~..xJ.WWr   r(   )r4   r5   r6   r7   r9   r:   
PathFinderrH   r8   listr<   r;   rI   r.   r   r   r>   r>   v   si    X&&11L !%	XX 3i$X 	X
 
			'	'$	.Xr   r>   _rfdetr_removed_findernamec                    | t         v r0t         d|  }	 t        j                  |      }|t	               | <   |S | t        v r!ddl	m
} t        ||       }|t	               | <   |S | t        v rNddlm} ddlm} t!        ||       rt        ||       }|t	               | <   |S t        |j#                  d            t%        d	t        d
|       # t
        $ r(}|j                  |k7  r t        t         |          dd}~ww xY w)a  Lazily resolve training/PTL and plus-only exports and handle removed-module aliases.

    This hook is only invoked on explicit attribute access (e.g. ``rfdetr.RFDETRModelModule``) and supports three
    behaviors:

    * Training/PTL exports (names in ``_LAZY_TRAINING``) are imported from ``rfdetr.training``
      on first use to avoid importing PyTorch Lightning at ``import rfdetr`` time.
    * Plus-only exports (names in ``_PLUS_EXPORTS``) are imported from ``rfdetr.platform.models``,
      and a descriptive ``ImportError`` is raised with an installation hint if the model is not available.
    * Removed-module aliases (keys in ``_REMOVE_IN_VERSION_1_9``, such as ``util`` and ``deploy``)
      are first attempted via a shim submodule (e.g. ``rfdetr.util``); once the shim files are removed, a migration-hint
      ``ImportError`` is raised instead of silently masking unrelated nested import errors.
    rB   Nr   )training)_INSTALL_MSG)modelszplatform model downloads)rQ   zmodule z has no attribute )rG   r4   r9   import_moduleglobalsModuleNotFoundErrorrQ   r2   _LAZY_TRAININGrfdetrrS   getattr_PLUS_EXPORTSrfdetr.platformrT   rU   hasattrformatAttributeError)rQ   module_namevalueexc	_trainingrT   _platform_modelss          r   __getattr__rf      s    %%!
!D6*	F++K8E#GIdOL ~0	4(	$}0>#T*,d3E#GIdOL,--3M-NOO
78,.@I
JJ1 # 	Fxx;&4T:;E		Fs   #C 	C>#C99C>)5r7   r9   importlib.abcimportlib.machineryimportlib.utilossystypingr   numpy_IS_NUMPY_INSTALLEDr2   r^   r[   _complex128r   rfdetr.detrr   rfdetr.inferencer   rfdetr.variantsr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   __all__r8   PathLiker   	frozensetrY   r\   rG   abcLoaderr%   MetaPathFinderr>   _REMOVED_MODULE_FINDER	meta_pathinsertrP   rf   r.   r   r   <module>r|      sY  (     	 
 
  wuj9%t4K$  )   ""2#C 00 2C 2F 2 UV?N;<
 SS 39==// 3X9==77 X4 ./ s,e4MM23!%C,Kc ,K]    s   D" "D-,D-