Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6539] Fixed archiving gv addons #10851

Open
wants to merge 2 commits into
base: feature/gravy_valet_integration
Choose a base branch
from

Conversation

opaduchak
Copy link
Contributor

Purpose

Changes

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

include_path = f'external_{gv_account_data.resource_type.split('-')[1]}_service',
service_wb_key = gv_account_data.get_included_attribute(
include_path=include_path,
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to consistent with current stage configuration. If wb_key for citation addons is configured properly, we may replace it with

Suggested change
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
attribute_name='wb_key'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will we also need to do this for computing addons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we set wb_key in GV admin, we won't

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have two PRs that fix this problem. In the first one, is I added external_service_name to the GV ExternalService serializer. And I changed make_ephemeral_user_settings and make_ephemeral_node_settings in this PR.

include_path = ('base_account', f'external_{addon_type}_service')
service_wb_key = gv_addon_data.get_included_attribute(
include_path=include_path,
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to consistent with current stage configuration. If wb_key for citation addons is configured properly, we may replace it with

Suggested change
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
attribute_name='wb_key'

'operation_kwargs': {},
'operation_name': 'list_collection_items',
'operation_kwargs': {
'collection_id': addon['attributes']['root_folder'] if list_id == 'ROOT' else list_id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've noticed the issue when actual root items would be fetched instead if child items of configured root. This resolves it
@adlius fyi

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I fixed this issue in another PR. What I did is if there is a list_id I would always invoke list_collection_items. The Pr is here.

Comment on lines +299 to +307
def _initialize_ephemeral_storage_node_settings():
from addons.base.models import BaseStorageAddon

global _StorageEphemeralNodeSettings

class StorageEphemeralNodeSettings(EphemeralNodeSettings, BaseStorageAddon):
pass

_StorageEphemeralNodeSettings = StorageEphemeralNodeSettings
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not happy with this approach either, so I am more than welcome to suggestions

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm afraid I don't have any other suggestions.

Copy link
Contributor

@Johnetordoff Johnetordoff Dec 13, 2024

Choose a reason for hiding this comment

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

Might avoid using a global with this:

def _initialize_ephemeral_storage_node_settings():
    if not hasattr(_initialize_ephemeral_storage_node_settings, "_storage_node_settings"):
        from addons.base.models import BaseStorageAddon

        class StorageEphemeralNodeSettings(EphemeralNodeSettings, BaseStorageAddon):
            pass

        _initialize_ephemeral_storage_node_settings._storage_node_settings = StorageEphemeralNodeSettings

    return _initialize_ephemeral_storage_node_settings._storage_node_settings

_StorageEphemeralNodeSettings = _initialize_ephemeral_storage_node_settings()

I think that cover any import problems with a global.

Comment on lines +299 to +307
def _initialize_ephemeral_storage_node_settings():
from addons.base.models import BaseStorageAddon

global _StorageEphemeralNodeSettings

class StorageEphemeralNodeSettings(EphemeralNodeSettings, BaseStorageAddon):
pass

_StorageEphemeralNodeSettings = StorageEphemeralNodeSettings
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm afraid I don't have any other suggestions.

include_path = f'external_{gv_account_data.resource_type.split('-')[1]}_service',
service_wb_key = gv_account_data.get_included_attribute(
include_path=include_path,
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will we also need to do this for computing addons?

Copy link
Collaborator

@adlius adlius left a comment

Choose a reason for hiding this comment

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

I have some other PRs that I made that fixed some of the issues. I think you might want to take a look at those:
https://github.com/CenterForOpenScience/gravyvalet/pull/178/files
https://github.com/CenterForOpenScience/osf.io/pull/10837/files

'operation_kwargs': {},
'operation_name': 'list_collection_items',
'operation_kwargs': {
'collection_id': addon['attributes']['root_folder'] if list_id == 'ROOT' else list_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I fixed this issue in another PR. What I did is if there is a list_id I would always invoke list_collection_items. The Pr is here.

include_path = f'external_{gv_account_data.resource_type.split('-')[1]}_service',
service_wb_key = gv_account_data.get_included_attribute(
include_path=include_path,
attribute_name='external_service_name' if addon_type == AddonType.CITATION else 'wb_key'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have two PRs that fix this problem. In the first one, is I added external_service_name to the GV ExternalService serializer. And I changed make_ephemeral_user_settings and make_ephemeral_node_settings in this PR.

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.

4 participants