Skip to content

Commit cda0734

Browse files
committed
Only report package versions once
1 parent b033446 commit cda0734

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

src/blueapi/core/context.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,35 +217,31 @@ def find_device(self, addr: str | list[str]) -> Device | None:
217217
def with_config(self, config: EnvironmentConfig) -> None:
218218
if config.metadata is not None:
219219
self.run_engine.md |= config.metadata.model_dump()
220+
220221
package_map = metadata.packages_distributions()
222+
packages = {src.module.split(".")[0] for src in config.sources}
223+
for pkg in packages:
224+
if root_pkg := package_map.get(pkg):
225+
version = metadata.version(root_pkg[0])
226+
LOGGER.info("Using package %s[%s]", root_pkg[0], version)
227+
221228
for source in config.sources:
222229
mod = import_module(source.module)
223230

224-
if root_pkg := package_map.get(source.module.split(".")[0]):
225-
version = metadata.version(root_pkg[0])
226-
loc = mod.__spec__ and mod.__spec__.origin
227-
summary = f"{root_pkg[0]}[version: {version}, location: {loc}]"
228-
else:
229-
summary = ""
230-
231231
match source:
232232
case PlanSource():
233-
LOGGER.info("Including plans from %s (%s)", source.module, summary)
233+
LOGGER.info("Including plans from %s", source.module)
234234
self.with_plan_module(mod)
235235
case DeviceSource():
236-
LOGGER.info(
237-
"Including devices from %s (%s)", source.module, summary
238-
)
236+
LOGGER.info("Including devices from %s", source.module)
239237
LOGGER.warning(
240238
"'devices' environment kind is deprecated - please convert "
241239
"configuration to use deviceManager"
242240
)
243241
self.with_device_module(mod)
244242
case DodalSource(mock=mock):
245243
LOGGER.info(
246-
"Including devices from 'dodal' source %s (%s)",
247-
source.module,
248-
summary,
244+
"Including devices from 'dodal' source %s", source.module
249245
)
250246
LOGGER.warning(
251247
"'dodal' environment kind is deprecated - please convert "
@@ -254,10 +250,9 @@ def with_config(self, config: EnvironmentConfig) -> None:
254250
self.with_dodal_module(mod, mock=mock)
255251
case DeviceManagerSource(mock=mock, name=name):
256252
LOGGER.info(
257-
"Including devices from 'deviceManager' source %s:%s (%s)",
253+
"Including devices from 'deviceManager' source %s:%s",
258254
source.module,
259255
name,
260-
summary,
261256
)
262257
manager = getattr(mod, name)
263258
if not isinstance(manager, DeviceManager):

0 commit comments

Comments
 (0)