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

Problem: API for defining metadata plugins is ill-defined #28

Closed
jrwdunham opened this issue Oct 2, 2017 · 2 comments
Closed

Problem: API for defining metadata plugins is ill-defined #28

jrwdunham opened this issue Oct 2, 2017 · 2 comments
Assignees

Comments

@jrwdunham
Copy link
Contributor

The following PRs introduce PREMIS-related functionality to metsrw:

The Write pointer files PR #27 introduces an informal plugin system that allows metsrw's METSDocument class to know how to work with different metadata standards, in this case PREMIS. The API for this plugin system needs to be analyzed and explicitly defined so that it can be used, e.g., to convert PR #20's PREMIS work to a plugin.

Here is how the metsrw plugin system currently works. The constructor of the METSDocument class now accepts a plugins kwarg which should be a dict mapping mdType values (e.g., 'PREMIS:OBJECT') to classes. Those classes are expected to have a class method fromtree which takes an lxml._Element instance (provided by metsrw' FSEntry) and returns an instance of the plugin's representation of the metadata element, cf. the PREMISRW plugin. This allows one to call METSDocument(plugins=my_plugins).get_file(file_uuid=my_file_uuid).get_premis_objects() and get PREMIS objects as the anticipated type of Python instance.

In the other direction, mets_fs_entry.add_premis_object(premis_object.serialize()) is how a PREMIS metadata element is currently added to an existing metsrw FSEntry instance.

In summary, under the API implicit in PR #27, metadata plugins must be classes that provide:

  1. a fromtree class method that creates an instance given an lxml._Element instance as input, and
  2. a serialize instance method that returns an lxml._Element instance.

This ^ API is definitely not written in stone. But it is a start...

@jrwdunham jrwdunham changed the title Problem: API for deining metadata plugins is ill-defined Problem: API for defining metadata plugins is ill-defined Oct 9, 2017
@jrwdunham
Copy link
Contributor Author

The metsrw commit cf12834 (part of PR #27) introduces functionality that should facilitate the creation of PREMIS plugins that conform to the API declared by the FSEntry class.

@jrwdunham
Copy link
Contributor Author

I am closing this because the plugin (dependency injection) system seems to address this. The FSEntry class now declares its dependencies via class methods that valuate to Dependency instances which are passed assertions about the dependency, e.g.:

>>> premis_object_class = Dependency(
...     has_methods('serialize'),
...     has_class_methods('fromtree'),
...     is_class)

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

No branches or pull requests

2 participants