Skip to content

New ExportProvider and ImportProvider#1

Draft
lauraBahamon wants to merge 112 commits into
rdmorganiser:mainfrom
MPDL:dev
Draft

New ExportProvider and ImportProvider#1
lauraBahamon wants to merge 112 commits into
rdmorganiser:mainfrom
MPDL:dev

Conversation

@lauraBahamon
Copy link
Copy Markdown

No description provided.

Laura Bahamon added 30 commits February 12, 2025 14:47
… method to temporarily replace rdmo.services.providers.OauthProviderMixin class
@lauraBahamon lauraBahamon changed the title neues Export Plugin New ExportProvider and ImportProvider Feb 16, 2026
@lauraBahamon
Copy link
Copy Markdown
Author

In the context of our MAUS project we forked this repository and develop further plugins for GitHub.

Export Provider

This provider plugin enables users to export project data to new or existing repositories on GitHub.

Project data is generated with RDMO's file export plugins (XML, CSV and JSON) for all projects. SMP projects have some additional export choices that are provided by our rdmo-plugins-maus. Currently, these choices are: a README.md, a CITATION.cff, a LICENSE, and an SMP report (a document containing all the project content in the form of a report).

These SMP-specific export choices are created with views that use attributes of the SMP catalog. Our hope is that, in the process of standardizing the RDMO attributes, the SMP-specific views will create usable files for every other catalog, not only SMP.

Import Provider

This provider plugin enables users to import project data from public or private GitHub repositories.

Similar to the existing GitHubImport class, the new plugin enables the import of RDMO XML project files. This new plugin also allows users to import repository metadata (license, languages, dependency graph, and CITATION.cff).

The metadata import is optimized for SMP projects because other catalogs may not have matching questions (and attributes) for the metadata or use different attributes. In those cases, the plugin only imports the usable subset of repository metadata.

SMP Catalog

All the changes use a new version of the SMP catalog. Here is our forked repository rdmo-catalog with the modified SMP catalog as well as the new views for the export choices.

Other changes

1. Radio Select displaying the most recently updated, accessible GitHub repositories for each user

The existing plugins have been modified so that their form displays an overview of repositories to choose from (instead of an input field to write the repository url).

This overview is filtered by the rights needed for the selected action (import or export). For example, when using the import plugin, the user only sees the repositories for which they have read access. The repository list for the export plugin may vary, because it lists those repositories for which the user has write access.

2. Modification to class IntegrationCreateView

In order to include the list of accessible repositories for each user in the GitHubIssueProvider class of this repository, we had to modify the RDMO class IntegrationCreateView. This involved adding a setup method that checks if the integration provider has a method called integration_setup and runs it. Here is our modified code.

3. Import and export choices form field

Both the import and export provider plugins use a custom multiple-choice field provided by our rdmo-plugins-maus. Checkout the repository's README.md for more info.


{% bootstrap_form submit=_('Export to GitHub') %}

<style>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should move to the head block.


{{ block.super }}

<style>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should move to the head block.

Comment thread rdmo_github/forms/custom_validators.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should just be named validadors.py and directly to rdmo_github. Same with forms.py.

Comment thread rdmo_github/providers/exports.py Outdated
base64_bytes_of_content = base64.b64encode(binary)
base64_string_of_content = base64_bytes_of_content.decode('utf-8')
choice_content = base64_string_of_content
except:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Genereally, except should not be used without a specific exception to catch. Here it would be better to use

if not response.content:
    ...

anyway.


exports = form_data['exports']
processed_exports = []
for e in exports:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for export in exports:

Comment thread rdmo_github/providers/exports.py Outdated

try:
response.raise_for_status()
except Exception as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To generic, for requests you can use:

try:
    response.raise_for_status()
except requests.exceptions.HTTPError as e:
    ...

Comment thread rdmo_github/providers/imports.py Outdated
new_values = [v for v in xml_import_plugin.values if v.attribute]
xml_import_plugin.values = new_values

author_attribute_uris = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Static lists like this could go to the top of the class, maybe this could be separated into a maus and non-maus part.

@jochenklar
Copy link
Copy Markdown
Member

jochenklar commented Apr 2, 2026

We can check the settings for the plugin like this:

# in apps.py
from django.apps import AppConfig


class RDMOGitHubConfig(AppConfig):
    name = 'rdmo_github'

    def ready(self):
        import rdmo_github.checks  # noqa: F401

# in checks.py
from django.conf import settings
from django.core.checks import Error, register


@register()
def check_github_provider_settings(app_configs, **kwargs):
    errors = []

    try:
        provider = settings.GITHUB_PROVIDER
    except AttributeError:
        errors.append(
            Error('settings.GITHUB_PROVIDER does not exist.', hint='Add GITHUB_PROVIDER to config/settings/local.py')
        )
    else:
        for key in ['client_id', 'client_secret', 'app_type', 'github_app_name']:
            if not provider.get(key):
                errors.append(Error(f'Key "{key}" is missing from settings.GITHUB_PROVIDER')
        )

    return errors

@jochenklar
Copy link
Copy Markdown
Member

For the setup and automatic formatting, you can use the files in dev of https://github.com/rdmorganiser/rdmo-plugins-orcid as template:

pre-commit install
pre-commit run --all

should then run the hooks.

If the typos catches the translation files, it can be configured like here: https://github.com/rdmorganiser/rdmo/blob/main/.pre-commit-config.yaml#L41

Laura Bahamon added 13 commits April 27, 2026 10:37
… parameters in the script tag in the forms' Media classes
…edia classes to define starting style of the form templates
…ing parameters from template context, and include code to append more repos in form's repo radio buttons
…ing parameters from template context, and include code to 1. append more repos in form's repo radio buttons and 2. cover xml file import for projects without the smp catalogue
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