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

SN wrangler_utils add set_property #33

Merged
merged 7 commits into from
Jun 12, 2024
Merged

Conversation

sarahgonicholson
Copy link
Collaborator

Adds function set_property to wrangler_utils.py that can patch property values by uuid.

Copy link
Member

@alexander-veit alexander-veit left a comment

Choose a reason for hiding this comment

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

Please add your function to the wrangler_utils CLI, like the other functions. That might require a slight change of your function arguments.

def set_property(
uuid: str,
prop_key: str,
prop_value: Union[str,int],
Copy link
Member

Choose a reason for hiding this comment

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

prop_value could also be a list. Any is probably fine here. Validation will be done portal side anyway and it will fail if we try to patch some unexpected.

ff_utils.patch_metadata(patch_body, obj_id=uuid, key=smaht_key)
print(f"Set item {uuid} property {prop_key} to {prop_value}.")
except Exception as e:
raise Exception(f"Item could not be PATCHed: {e}")
Copy link
Member

Choose a reason for hiding this comment

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

We might need str(e) here. This might be wrong in other places. Please correct those as well.

@alexander-veit
Copy link
Member

Actually your function args should be fine.

@click.help_option("--help", "-h")
@click.option(
"-m",
"--mwfr-identifier",
Copy link
Member

Choose a reason for hiding this comment

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

This should -i and --identifier

type=str,
help="Name of environment in smaht-keys file",
)
def set_property(mwfr_identifier,property_key,property_value,auth_env):
Copy link
Member

Choose a reason for hiding this comment

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

mwfr_identifier => identifier

@sarahgonicholson sarahgonicholson merged commit 68bec8a into master Jun 12, 2024
4 checks passed
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