2121import warnings
2222from enum import Enum
2323from importlib .metadata import version
24- from typing import Any
2524
2625_DEFAULT_API_KEY = 'default-api-secret-that-is-long-enough'
2726
@@ -31,7 +30,6 @@ class ModeEnum(str, Enum):
3130 DEVELOPMENT = 'development'
3231
3332
34- import yaml
3533from pydantic import BaseModel , ConfigDict , Field , field_validator , model_validator
3634
3735try :
@@ -42,8 +40,6 @@ class ModeEnum(str, Enum):
4240
4341from importlib .metadata import entry_points
4442
45- from nomad .common import get_package_path
46-
4743from .common import ConfigBaseModel , Options
4844from .north import NORTH
4945from .plugins import EntryPointType , PluginPackage , Plugins
@@ -1153,12 +1149,7 @@ def load_plugins(self):
11531149 function.
11541150 """
11551151 from nomad .config import _merge , _plugins
1156- from nomad .config .models .plugins import (
1157- Normalizer ,
1158- NorthToolEntryPoint ,
1159- Parser ,
1160- Schema ,
1161- )
1152+ from nomad .config .models .plugins import NorthToolEntryPoint
11621153
11631154 if self .plugins is None :
11641155
@@ -1244,36 +1235,6 @@ def get_config(key):
12441235 id = key , north_tool = tool
12451236 )
12461237
1247- # Handle plugins defined in nomad.yaml (old plugin mechanism)
1248- def load_plugin_yaml (name , values : dict [str , Any ]):
1249- """Loads plugin metadata from nomad_plugin.yaml"""
1250- python_package = values .get ('python_package' )
1251- if not python_package :
1252- raise ValueError (
1253- f'Could not find python_package for plugin entry point: { name } .'
1254- )
1255-
1256- package_path = values .get ('package_path' )
1257- if package_path is None :
1258- package_path = get_package_path (python_package )
1259- values ['package_path' ] = package_path
1260-
1261- metadata_path = os .path .join (package_path , 'nomad_plugin.yaml' )
1262- if os .path .exists (metadata_path ):
1263- try :
1264- with open (metadata_path , encoding = 'UTF-8' ) as f :
1265- metadata = yaml .load (f , Loader = yaml .SafeLoader )
1266- except Exception as e :
1267- raise ValueError (
1268- f'Cannot load plugin metadata file { metadata_path } .' , e
1269- )
1270-
1271- for key , value in metadata .items ():
1272- if key not in values :
1273- values [key ] = value
1274-
1275- return values
1276-
12771238 for key , plugin in _plugins ['entry_points' ]['options' ].items ():
12781239 if key not in plugin_entry_point_ids :
12791240 if isinstance (plugin , dict ):
@@ -1282,15 +1243,8 @@ def load_plugin_yaml(name, values: dict[str, Any]):
12821243 plugin ['id' ] = key
12831244 # Update information for old style plugins
12841245 else :
1285- plugin_config = load_plugin_yaml (key , plugin )
1286- plugin_config ['id' ] = key
1287- plugin_class = {
1288- 'parser' : Parser ,
1289- 'normalizer' : Normalizer ,
1290- 'schema' : Schema ,
1291- }.get (plugin_config ['plugin_type' ])
1292- _plugins ['entry_points' ]['options' ][key ] = (
1293- plugin_class .model_validate (plugin_config )
1246+ raise ValueError (
1247+ f'Failed loading { key } plugin. Old style plugins are no longer supported.'
12941248 )
12951249
12961250 self .plugins = Plugins .model_validate (_plugins )
0 commit comments