Skip to content

Commit

Permalink
1319: Rename forgotten dependent names to depends (#124)
Browse files Browse the repository at this point in the history
* 1319: Rename forgotten dependent names to depends

- rename WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS to WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS.
- rename unterminated_dependent_subscriptions to unterminated_depends_on_subscriptions
- rename parent_block to in_use_by_block in tests.
- rename dependent to depends in tests.
- rename test_product_block_list_nested_db_parent to test_product_block_list_nested_db_in_use_by_block.
- rename test_product_block_one_nested_db_parent to test_product_block_one_nested_db_in_use_by_block.

* bumpversion to 0.4.0-rc3
  • Loading branch information
tjeerddie authored Mar 17, 2022
1 parent 893c4c8 commit 8f0e76f
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.0-rc2
current_version = 0.4.0-rc3
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((\-rc)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/application/openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/architecture/application/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ These workflows have more in common with each other than not, it's mostly a matt
By default, the associated workflow can only be run on a subscription with a lifecycle state set to `ACTIVE`. This behavior can be changed in the following data structure in the `workflows/__init__.py` file:

```python
from orchestrator.services.subscriptions import WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS
from orchestrator.services.subscriptions import WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS

WF_USABLE_MAP.update(
{
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

"""This is the orchestrator workflow engine."""

__version__ = "0.4.0-rc2"
__version__ = "0.4.0-rc3"

from orchestrator.app import OrchestratorCore
from orchestrator.settings import app_settings, oauth2_settings
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/domain/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def domain_filter(instance: SubscriptionInstanceTable) -> bool:
to filter through instances depending on that attribute.
Args:
instance: dependent on subscription instance
instance: depends on subscription instance
Returns:
Boolean of match.
Expand Down
4 changes: 2 additions & 2 deletions orchestrator/schemas/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class WorkflowListItemSchema(OrchestratorBaseModel):
status: Optional[str]
action: Optional[str]
locked_relations: Optional[List[UUID]]
# unterminated_parents deprecated since "0.4.0" renamed to unterminated_dependent_subscriptions
# unterminated_parents deprecated since "0.4.0" renamed to unterminated_depends_on_subscriptions
unterminated_parents: Optional[List[UUID]]
unterminated_dependent_subscriptions: Optional[List[UUID]]
unterminated_depends_on_subscriptions: Optional[List[UUID]]


class SubscriptionWorkflowListsSchema(OrchestratorBaseModel):
Expand Down
26 changes: 13 additions & 13 deletions orchestrator/services/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def status_relations(subscription: SubscriptionTable) -> Dict[str, List[UUID]]:
"""
in_use_by_query = query_in_use_by_subscriptions(subscription.subscription_id)

unterminated_dependent_subscriptions = _terminated_filter(in_use_by_query)
unterminated_depends_on_subscriptions = _terminated_filter(in_use_by_query)
locked_in_use_by_block_relations = _in_sync_filter(in_use_by_query)

depends_on_query = query_depends_on_subscriptions(subscription.subscription_id)
Expand All @@ -466,9 +466,9 @@ def status_relations(subscription: SubscriptionTable) -> Dict[str, List[UUID]]:

result = {
"locked_relations": locked_in_use_by_block_relations + locked_depends_on_block_relations,
# unterminated_parents deprecated since "0.4.0", renamed to unterminated_dependent_subscriptions
"unterminated_parents": unterminated_dependent_subscriptions,
"unterminated_dependent_subscriptions": unterminated_dependent_subscriptions,
# unterminated_parents deprecated since "0.4.0", renamed to unterminated_depends_on_subscriptions
"unterminated_parents": unterminated_depends_on_subscriptions,
"unterminated_depends_on_subscriptions": unterminated_depends_on_subscriptions,
}

logger.debug(
Expand Down Expand Up @@ -496,9 +496,9 @@ def get_relations(subscription_id: UUIDstr) -> Dict[str, List[UUID]]:

WF_USABLE_MAP: Dict[str, List[str]] = {}

# WF_BLOCKED_BY_PARENTS deprecated since "0.4.0", renamed to WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS
# WF_BLOCKED_BY_PARENTS deprecated since "0.4.0", renamed to WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS
WF_BLOCKED_BY_PARENTS: Dict[str, bool] = {}
WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS: Dict[str, bool] = {}
WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS: Dict[str, bool] = {}

WF_USABLE_WHILE_OUT_OF_SYNC: List[str] = ["modify_note"]

Expand Down Expand Up @@ -560,20 +560,20 @@ def subscription_workflows(subscription: SubscriptionTable) -> Dict[str, Any]:
workflow_json["action"] = "terminated" if workflow.target == Target.TERMINATE else "modified"

# Check if this workflow is blocked because there are unterminated relations
blocked_by_dependent_subscriptions = WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS.get(
blocked_by_depends_on_subscriptions = WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS.get(
workflow.name, workflow.target == Target.TERMINATE
)

# WF_BLOCKED_BY_PARENTS deprecated since "0.4.0", renamed to WF_BLOCKED_BY_DEPENDENT_SUBSCRIPTIONS
if not blocked_by_dependent_subscriptions:
blocked_by_dependent_subscriptions = WF_BLOCKED_BY_PARENTS.get(
# WF_BLOCKED_BY_PARENTS deprecated since "0.4.0", renamed to WF_BLOCKED_BY_DEPENDS_ON_SUBSCRIPTIONS
if not blocked_by_depends_on_subscriptions:
blocked_by_depends_on_subscriptions = WF_BLOCKED_BY_PARENTS.get(
workflow.name, workflow.target == Target.TERMINATE
)
if blocked_by_dependent_subscriptions and data["unterminated_dependent_subscriptions"]:
if blocked_by_depends_on_subscriptions and data["unterminated_depends_on_subscriptions"]:
workflow_json["reason"] = "subscription.no_modify_subscription_in_use_by_others"
# unterminated_parents deprecated since "0.4.0", renamed to unterminated_dependent_subscriptions
# unterminated_parents deprecated since "0.4.0", renamed to unterminated_depends_on_subscriptions
workflow_json["unterminated_parents"] = data["unterminated_parents"]
workflow_json["unterminated_dependent_subscriptions"] = data["unterminated_dependent_subscriptions"]
workflow_json["unterminated_depends_on_subscriptions"] = data["unterminated_depends_on_subscriptions"]
workflow_json["action"] = "terminated" if workflow.target == Target.TERMINATE else "modified"

workflows[workflow.target.lower()].append(workflow_json)
Expand Down
12 changes: 6 additions & 6 deletions test/unit_tests/api/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def seed():
name="LightpathProduct",
description="Service product that lives on ports",
product_type="LightPath",
tag="LightPath", # This is special since parent/child subscription code handles specific tags
tag="LightPath", # This is special since in_use_by/depends_on subscription code handles specific tags
status="active",
product_blocks=product_blocks,
fixed_inputs=fixed_inputs,
Expand All @@ -68,7 +68,7 @@ def seed():
name="PortAProduct",
description="Port A description",
product_type="Port",
tag="SP", # This is special since parent/child subscription code handles specific tags
tag="SP", # This is special since in_use_by/depends_on subscription code handles specific tags
status="active",
product_blocks=product_blocks,
fixed_inputs=fixed_inputs,
Expand Down Expand Up @@ -445,9 +445,9 @@ def test_insync_invalid_tagged(seed, test_client):

def test_in_use_by_subscriptions(seed, test_client):
response = test_client.get(f"/api/subscriptions/in_use_by/{PORT_A_SUBSCRIPTION_ID}")
dependent_subs = response.json()
assert len(dependent_subs) == 1
assert SERVICE_SUBSCRIPTION_ID == dependent_subs[0]["subscription_id"]
depends_subs = response.json()
assert len(depends_subs) == 1
assert SERVICE_SUBSCRIPTION_ID == depends_subs[0]["subscription_id"]


def test_in_use_by_subscriptions_not_insync(seed, test_client):
Expand Down Expand Up @@ -484,7 +484,7 @@ def test_depends_on_subscriptions(seed, test_client):


def test_depends_on_subscriptions_not_insync(seed, test_client):
# ensure that the dependent subscription of the LP is out of sync
# ensure that the depends on subscription of the LP is out of sync
msp = SubscriptionTable.query.with_for_update().get(PORT_A_SUBSCRIPTION_ID)
msp.insync = False
db.session.commit()
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/domain/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from test.unit_tests.domain.products.product_blocks.product_block_list_nested import ( # noqa: F401
test_product_block_list_nested,
test_product_block_list_nested_db_parent,
test_product_block_list_nested_db_in_use_by_block,
)
from test.unit_tests.domain.products.product_blocks.product_block_one import ( # noqa: F401
test_product_block_one,
test_product_block_one_db,
)
from test.unit_tests.domain.products.product_blocks.product_block_one_nested import ( # noqa: F401
test_product_block_one_nested,
test_product_block_one_nested_db_parent,
test_product_block_one_nested_db_in_use_by_block,
)
from test.unit_tests.domain.products.product_blocks.product_block_with_list_union import ( # noqa: F401
test_product_block_with_list_union,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def test_product_block_list_nested():


@pytest.fixture
def test_product_block_list_nested_db_parent(resource_type_list, resource_type_int, resource_type_str):
parent_block = ProductBlockTable(
def test_product_block_list_nested_db_in_use_by_block(resource_type_list, resource_type_int, resource_type_str):
in_use_by_block = ProductBlockTable(
name="ProductBlockListNestedForTest", description="Test Block Parent", tag="TEST", status="active"
)
parent_block.resource_types = [resource_type_int]
in_use_by_block.resource_types = [resource_type_int]

db.session.add(parent_block)
db.session.add(in_use_by_block)
db.session.commit()

return parent_block
return in_use_by_block
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def test_product_block_one_nested():


@pytest.fixture
def test_product_block_one_nested_db_parent(resource_type_list, resource_type_int, resource_type_str):
parent_block = ProductBlockTable(
def test_product_block_one_nested_db_in_use_by_block(resource_type_list, resource_type_int, resource_type_str):
in_use_by_block = ProductBlockTable(
name="ProductBlockOneNestedForTest", description="Test Block Parent", tag="TEST", status="active"
)
parent_block.resource_types = [resource_type_int]
in_use_by_block.resource_types = [resource_type_int]

db.session.add(parent_block)
db.session.add(in_use_by_block)
db.session.commit()

return parent_block
return in_use_by_block
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class ProductTypeListNestedForTest(


@pytest.fixture
def test_product_list_nested(test_product_block_list_nested_db_parent):
def test_product_list_nested(test_product_block_list_nested_db_in_use_by_block):
product = ProductTable(
name="TestProductListNested", description="Test ProductTable", product_type="Test", tag="TEST", status="active"
)

fixed_input = FixedInputTable(name="test_fixed_input", value="False")

product_block = test_product_block_list_nested_db_parent
product_block = test_product_block_list_nested_db_in_use_by_block
product.fixed_inputs = [fixed_input]
product.product_blocks = [product_block]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class ProductTypeOneNestedForTest(


@pytest.fixture
def test_product_one_nested(test_product_block_one_nested_db_parent):
def test_product_one_nested(test_product_block_one_nested_db_in_use_by_block):
product = ProductTable(
name="TestProductOneNested", description="Test ProductTable", product_type="Test", tag="TEST", status="active"
)

fixed_input = FixedInputTable(name="test_fixed_input", value="False")

product_block = test_product_block_one_nested_db_parent
product_block = test_product_block_one_nested_db_in_use_by_block
product.fixed_inputs = [fixed_input]
product.product_blocks = [product_block]

Expand Down

0 comments on commit 8f0e76f

Please sign in to comment.