Skip to content

Conversation

@Shastick
Copy link
Contributor

@Shastick Shastick commented Jun 13, 2025

This prevents #1048 from breaking existing configurations.

Notes

Circular imports

Fixing required to move the subscription_params.py file to a separate module, otherwise we run into a circular import problem (the placeholder imports the class from the new path, but the class itself still imports the subscription_params).

The params module is a sibling of v21: making it a child module of v21 still yields the circular import error:

ImportError: cannot import name 'PlanningAreaResource' from partially initialized module 'monitoring.uss_qualifier.resources' (most likely due to a circular import) (/app/monitoring/uss_qualifier/resources/__init__.py)

User warnings

I tested that the import of the old resource in a configuration triggers the warning. With a single usage of the resource in f3548_self_contained, we get (see this test run):

Running configuration(s): configurations.dev.f3548_self_contained
2025-06-13 08:40:30.113 | INFO     | __main__:main:274 - ========== Running uss_qualifier for configuration configurations.dev.f3548_self_contained ==========
2025-06-13 08:40:30.149 | INFO     | __main__:run_config:180 - Validating configuration...
/app/monitoring/monitorlib/inspection.py:23: UserWarning: PlanningAreaResource has moved to new_module. Importing it from its current location is deprecated and will be removed in the future.
  if not hasattr(module_object, component):
/app/monitoring/monitorlib/inspection.py:29: UserWarning: PlanningAreaResource has moved to new_module. Importing it from its current location is deprecated and will be removed in the future.
  module_object = getattr(module_object, component)
2025-06-13 08:40:30.653 | DEBUG    | __main__:sign:95 - Computing signatures of inputs

[...]

If no configuration references the resource, we have no warning.

@Shastick Shastick force-pushed the fix-maintain-old-resource branch 5 times, most recently from 2a2b2d9 to e847075 Compare June 13, 2025 08:50
@Shastick Shastick marked this pull request as ready for review June 13, 2025 08:51
@Shastick Shastick force-pushed the fix-maintain-old-resource branch from e847075 to d88da2c Compare June 16, 2025 07:49
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

Have you considered something like this instead?

import warnings
from monitoring.uss_qualifier.resources import PlanningAreaResource as PlanningAreaResourceOrig, PlanningAreaSpecification

class PlanningAreaResource(PlanningAreaResourceOrig):

    def __init__(self, specification: PlanningAreaSpecification, resource_origin: str):
        super(PlanningAreaResource, self).__init__(specification, resource_origin)
        warnings.warn(
            "PlanningAreaResource has moved from 'resources.astm.f3548.v21' to 'resources'. Importing it from its current location is deprecated and will be removed in the future.",
            UserWarning,
            stacklevel=2,
        )

@@ -1,9 +1,8 @@
from __future__ import annotations

import datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

About SubscriptionParams: actually it looks like this is not a resource. This is never declared as such in a yaml file, nor used as a field in one. I feel like this may be better suited in monitorlib. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving to monitorlib indeed makes sense, will do

@Shastick
Copy link
Contributor Author

Have you considered something like this instead?

import warnings
from monitoring.uss_qualifier.resources import PlanningAreaResource as PlanningAreaResourceOrig, PlanningAreaSpecification

class PlanningAreaResource(PlanningAreaResourceOrig):

    def __init__(self, specification: PlanningAreaSpecification, resource_origin: str):
        super(PlanningAreaResource, self).__init__(specification, resource_origin)
        warnings.warn(
            "PlanningAreaResource has moved from 'resources.astm.f3548.v21' to 'resources'. Importing it from its current location is deprecated and will be removed in the future.",
            UserWarning,
            stacklevel=2,
        )

That would be simpler indeed. However, I just tried and I get this error:

ValueError: Test suite "ASTM F3548-21" expected resource planning_area to be resources.PlanningAreaResource, but instead it was provided monitoring.uss_qualifier.resources.astm.f3548.v21.planning_area.PlanningAreaResource

I guess the subclassing breaks an equality check, while the current approach ensures that the types are the exact same.

@Shastick Shastick force-pushed the fix-maintain-old-resource branch from 93069f7 to ae17102 Compare June 17, 2025 16:03
@Shastick Shastick requested a review from mickmis June 18, 2025 13:24
@Shastick Shastick force-pushed the fix-maintain-old-resource branch from ae17102 to 9321172 Compare June 18, 2025 13:26
@Shastick Shastick force-pushed the fix-maintain-old-resource branch from 9321172 to 85270a6 Compare June 19, 2025 07:46
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

I find this approach a bit barbarian but I can't find a better alternative. Let's hope it also does not have strange side effects. So let's go ahead with it :)

@mickmis mickmis merged commit 48f29fa into interuss:main Jun 19, 2025
21 checks passed
@mickmis mickmis deleted the fix-maintain-old-resource branch June 19, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants