Skip to content

BAMresearch/masterdata-parser-example

Repository files navigation

masterdata-parser-example

An example parser for openBIS using the bam-masterdata interface.

This repository is intended to be used as a template or example to be forked to generate new parsers in openBIS integrated with the openbis-upload-helper.

1. Create a new parser repository

You can either fork or use this repository as a template.

Click on the button Use this template and choose Create a new repository:

use-this-template

You will be prompted to create a new repository. Choose:

  • Place to host the repository (organization or your own profile). In our case, we selected BAMResearch
  • Give a name. We named our repository masterdata-parser-nerxiv
  • Write a short description.
  • Choose Public visibility.
create-new-template

2. Define your parser entry point

With your new repository created, clone it locally:

git clone https://github.com/BAMresearch/masterdata-parser-example.git

Note: we will be using our example with this repository to showcase the commands. Please, change the corresponding paths to your own repository naming conventions.

We have now a new folder, masterdata-parser-example, containing the following structure:

masterdata-parser-example
├── LICENSE
├── pyproject.toml
├── README.md
├── src
│   ├── masterdata_parser_example
│       ├── __init__.py
│       ├── parser.py
│       └── _version.py
└── tests
    ├── __init__.py
    ├── conftest.py
    └── test_parser.py

Below you can find an explanation of each file. You can also change the name of the package from masterdata_parser_example to your preferred package name <pkg-name>.

In order to create your new parser, you have to:

  1. Define a new class in src/<pkg-name>/parser.py instead of MasterdataParserExample. We recommend naming it PkgName.
  2. Modify src/<pkg-name>/__init__.py entry point variables:
from .parser import PkgName

# Add more metadata if needed
<pkg-name>_entry_point = {
    "name": "PkgName",
    "description": "A new parser for masterdata.",
    "parser_class": PkgName,
}
  1. Modify the pyproject.toml line [project.entry-points."bam.parsers"] to the new entry point:
<pkg-name>_entry_point = "<pkg-name>:<pkg-name>_entry_point"
  1. Modify all other parts in pyproject.toml where the <pkg-name> is masterdata_parser_example to your package name.

Explanation of the files

To be added!

3. Work in your parser

With the new structure, you can work in your parser to map data from your files into openBIS by modifying src/<pkg-name>/parser.py and the testing module tests/test_parser.py.

4. Add new parser to openbis-upload-helper

Once your new parser has been developed and tested, you can add it to the registry of parsers in the openbis-upload-helper. We recommend you contacting the maintainers of the application with a link to your parser repository.

About

An example parser for openBIS using the bam-masterdata interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages