Skip to content

[PNE-6647] Tag default DS with settings object.#992

Merged
anoto-moniz merged 1 commit intomainfrom
feature/pne-6647-ds-store-default-settings
Jun 3, 2025
Merged

[PNE-6647] Tag default DS with settings object.#992
anoto-moniz merged 1 commit intomainfrom
feature/pne-6647-ds-store-default-settings

Conversation

@anoto-moniz
Copy link
Copy Markdown
Collaborator

@anoto-moniz anoto-moniz commented May 22, 2025

Citrine Python PR

When creating a design space, the endpoint accepts a dict of the settings which were used to create it. To make this process transparent from a user perspective, any design space which is created with create_default will have the settings dict attached to it in non-public field. So when the user goes to register it, the settings object will automatically be included.

Additionally, when retrieving a design space from the backend, those settings are part of the metadata. They will be captured in a non-public field, so if a user turns around and registers the design space object again, this copy will contain those settings.

Description

Please briefly explain the goal of the changes/this PR.
The reviewer should be able to understand why the change is being made by reading this description
and its links (e.g. JIRA tickets).

PR Type:

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Maintenance (non-breaking change to assist developers)

Adherence to team decisions

  • I have added tests for 100% coverage
  • I have written Numpy-style docstrings for every method and class.
  • I have communicated the downstream consequences of the PR to others.
  • I have bumped the version in __version__.py

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My local machine raised flake8 failures without these blank lines. ¯_(ツ)_/¯

@anoto-moniz anoto-moniz force-pushed the feature/pne-6647-ds-store-default-settings branch 2 times, most recently from 784af3a to e192151 Compare May 29, 2025 18:45

"""

_settings = properties.Optional(properties.Object(DesignSpaceSettings), "metadata.settings")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These settings are just metadata intended to be carried to DS registration, not for users to tinker with. The only effect messing with them will have is screwing up filtering in the UI.


"""

_settings = properties.Optional(properties.Object(DesignSpaceSettings), "metadata.settings")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

See above.

Comment on lines +185 to +186
if self._settings:
data["settings"] = self._settings.dump()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note that for registration, they're added in a different place than they're read. This is intentional.

Comment on lines +57 to +58
if self._settings:
data["settings"] = self._settings.dump()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

See above.

CreationType = TypeVar('CreationType', bound=DesignSpace)


class DefaultDesignSpaceMode(BaseEnumeration):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Although the class definition is moved, since it's still being imported here, it will not break user imports.

dsc.delete(uuid.uuid4())


def test_carrying_settings_from_create_default(valid_product_design_space):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This and the following test check the new behavior explicitly.

When creating a design space, the endpoint accepts a dict of the
settings which were used to create it. To make this process transparent
from a user perspective, any design space which is created with
create_default will have the settings dict attached to it in non-public
field. So when the user goes to register it, the settings object will
automatically be included.

Additionally, when retrieving a design space from the backend, those
settings are part of the metadata. They will be captured in a non-public
field, so if a user turns around and registers the design space object
again, this copy will contain those settings.
@anoto-moniz anoto-moniz force-pushed the feature/pne-6647-ds-store-default-settings branch from e192151 to 1069baa Compare May 29, 2025 18:51
@anoto-moniz anoto-moniz marked this pull request as ready for review May 29, 2025 18:53
@anoto-moniz anoto-moniz requested a review from a team as a code owner May 29, 2025 18:53
Copy link
Copy Markdown
Collaborator

@kroenlein kroenlein left a comment

Choose a reason for hiding this comment

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

This looks good. I kinda wish the DesignSpaceSettings objects were in factories.py, but that is not strictly necessary.

@anoto-moniz anoto-moniz merged commit 67cc0d1 into main Jun 3, 2025
17 checks passed
@anoto-moniz anoto-moniz deleted the feature/pne-6647-ds-store-default-settings branch June 3, 2025 16:47
@anoto-moniz
Copy link
Copy Markdown
Collaborator Author

This looks good. I kinda wish the DesignSpaceSettings objects were in factories.py, but that is not strictly necessary.

Isn't factories.py only on the tests side?

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