Skip to content

Commit 8b0d8fe

Browse files
committed
Fix name of pkg
Added readme
1 parent 61b0818 commit 8b0d8fe

File tree

4 files changed

+87
-4
lines changed

4 files changed

+87
-4
lines changed

README.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
11
# masterdata-parser-example
2-
An example parser and masterdata definitions for openBIS.
2+
3+
An example parser for openBIS using the bam-masterdata interface.
4+
5+
This repository is intended to be used as a template or example to be forked to generate new parsers in openBIS
6+
integrated with the `openbis-upload-helper`.
7+
8+
9+
## 1. Create a new parser repository
10+
11+
You can either [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) or [use this repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) as a template.
12+
13+
Click on the button **Use this template** and choose **Create a new repository**:
14+
15+
<!--Image use this template-->
16+
17+
You will be prompted to create a new repository. Choose:
18+
- Place to host the repository (organization or your own profile). In our case, we selected _BAMResearch_
19+
- Give a name. We named our repository _masterdata-parser-nerxiv_
20+
- Write a short description.
21+
- Choose _Public_ visibility.
22+
23+
<!-- Image of create a new repository -->
24+
25+
26+
## 2. Define your parser entry point
27+
28+
With your new repository created, clone it locally:
29+
```bash
30+
git clone https://github.com/BAMresearch/masterdata-parser-example.git
31+
```
32+
33+
**Note**: we will be using our example with this repository to showcase the commands. Please, change the corresponding
34+
paths to your own repository naming conventions.
35+
36+
We have now a new folder, `masterdata-parser-example`, containing the following structure:
37+
```sh
38+
masterdata-parser-example
39+
├── LICENSE
40+
├── pyproject.toml
41+
├── README.md
42+
├── src
43+
│ ├── masterdata_parser_example
44+
│ ├── __init__.py
45+
│ ├── parser.py
46+
│ └── _version.py
47+
└── tests
48+
├── __init__.py
49+
├── conftest.py
50+
└── test_parser.py
51+
```
52+
53+
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>`.
54+
55+
In order to create your new parser, you have to:
56+
1. Define a new class in `src/<pck-name>/parser.py` instead of `MasterdataParserExample`. We recommend naming it `PckName`.
57+
2. Modify `src/<pck-name>/__init__.py` entry point variables:
58+
```python
59+
from .parser import PckName
60+
61+
# Add more metadata if needed
62+
<pck_name>_entry_point = {
63+
"name": "PckName",
64+
"description": "A new parser for masterdata.",
65+
"parser_class": PckName,
66+
}
67+
```
68+
3. Modify the `pyproject.toml` line `[project.entry-points."bam.parsers"]` to the new entry point:
69+
```toml
70+
<pck-name>_entry_point = "<pck-name>:<pck_name>_entry_point"
71+
```
72+
4. Modify all other parts in `pyproject.toml` where the `<pck-name>` is `masterdata_parser_example` to your package name.
73+
74+
### Explanation of the files
75+
76+
_To be added!_
77+
78+
## 3. Work in your parser
79+
80+
With the new structure, you can work in your parser to map data from your files into openBIS by modifying `src/<pck-name>/parser.py` and the testing
81+
module `tests/test_parser.py`.
82+
83+
## 4. Add new parser to `openbis-upload-helper`
84+
85+
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.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dev = [
4343

4444
[tool.ruff]
4545
# Exclude a variety of commonly ignored directories.
46-
include = ["src/masterdata_example_parser/*.py", "tests/*.py"]
46+
include = ["src/masterdata_parser_example/*.py", "tests/*.py"]
4747
exclude = [
4848
".bzr",
4949
".direnv",
@@ -124,7 +124,7 @@ package-dir = { "" = "src" }
124124
where = ["src"]
125125

126126
[tool.setuptools_scm]
127-
write_to = "src/masterdata_example_parser/_version.py"
127+
write_to = "src/masterdata_parser_example/_version.py"
128128

129129
[project.entry-points."bam.parsers"]
130-
masterdata_parser_example_entry_point = "masterdata_example_parser:masterdata_parser_example_entry_point"
130+
masterdata_parser_example_entry_point = "masterdata_parser_example:masterdata_parser_example_entry_point"

0 commit comments

Comments
 (0)