Skip to content

Improve performance when using a non-admin user#1062

Open
whikloj wants to merge 5 commits into
mjordan:mainfrom
whikloj:improve_performance
Open

Improve performance when using a non-admin user#1062
whikloj wants to merge 5 commits into
mjordan:mainfrom
whikloj:improve_performance

Conversation

@whikloj
Copy link
Copy Markdown
Contributor

@whikloj whikloj commented Feb 18, 2026

Link to Github issue or other discussion

#1061

What does this PR do?

Reduces multiple requests for field configuration data to a single request for an entity/bundle

What changes were made?

  1. Along with changes in Improve performance islandora_workbench_integration#46
  2. Changes the return type of get_entity_fields() from list to dict with field_name: field_info,
    • when using an administrator user field_info == field_name (i.e. {"field_some": "field_some", "field_other": "field_other"})
    • when using use_workbench_permission field_info = {'config': <field configuration>, 'storage_config': <field storage configuration>}
  3. Refactors the common parts of in get_field_definition() for each entity type to reduce the function.

How to test / verify this PR?

Run a --check of any action with both an administrator user and a non-admin user. There should be no difference except for (hopefully) some improvement in speed.

I am fixing some orphans and using a simple config like this

task: update
host: https://dams-ng.lib.umanitoba.ca
#username: workbench_user
#password: <workbench_user_password>
#use_workbench_permissions: True
username: jwhiklo
password: <jwhiklo_password>
input_dir: /Users/jaredwhiklo/www/DAM2/islandora_workbench_dup
input_csv: test.csv
include_password_in_rollback_config_file: true
id_field: ID
secure_ssl_only: False
csv_field_templates:
 - field_member_of: 233
protected_vocabularies:
 - islandora_model
 - islandora_display
 - islandora_media_use
ignore_csv_columns:
 - 'RELS_EXT_isMemberOf_uri_ms'
 - 'RELS_EXT_isPageNumber_literal_ms'
 - 'RELS_EXT_isSequenceNumber_literal_ms'
 - 'related_item_title_ms'
 - 'RELS_EXT_dateIssued_literal_ms'
 - 'RELS_EXT_hasModel_uri_ms'
 - 'date_original'

and a csv with just the node_id of the object's to fix the field_member_of on

Run as my user (administrator)

[/Users/jaredwhiklo/www/DAM2/islandora_workbench_dup] 
> time python workbench --config=fix_test.yaml --check
OK, connection to Drupal at https://dams-ng.lib.umanitoba.ca verified. Ignoring SSL certificates.
OK, configuration file has all required values (did not check for optional values).
OK, CSV file /Users/jaredwhiklo/www/DAM2/islandora_workbench_dup/test.csv found.
OK, all 14 rows in the CSV file have the same number of columns as there are headers (2).
OK, CSV column headers match Drupal field names.
Configuration and input data appear to be valid. However, you should review your Workbench log after running --check.
python workbench --config=fix_test.yaml --check  3.59s user 0.45s system 9% cpu 43.563 total

Run as workbench_user

> time python workbench --config=fix_test.yaml --check
OK, connection to Drupal at https://dams-ng.lib.umanitoba.ca verified. Ignoring SSL certificates.
OK, configuration file has all required values (did not check for optional values).
OK, CSV file /Users/jaredwhiklo/www/DAM2/islandora_workbench_dup/test.csv found.
OK, all 14 rows in the CSV file have the same number of columns as there are headers (2).
OK, CSV column headers match Drupal field names.
Configuration and input data appear to be valid. However, you should review your Workbench log after running --check.
python workbench --config=fix_test.yaml --check  0.71s user 0.17s system 20% cpu 4.238 total

Interested Parties

@mjordan


Checklist

  • Before opening this PR, have you opened an issue explaining what you want to to do?
  • Have you included some configuration and/or CSV files useful for testing this PR?
  • Have you written unit or integration tests if applicable?
    I have not done this, but I could add some simple tests with pulled data from our development server.
  • Does the code added in this PR require a version of Python that is higher than the current minimum version?
  • If the changes in this PR require an additional Python library, have you included it in setup.py?
  • If the changes in this PR add a new configuration option, have you provided a default for when the option is not present in the .yml file?

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.

1 participant