Sherpa knowledge import plugins
Project description
Requirements
- Python 3.8+
- Flit to put Python packages and modules on PyPI
- Pydantic for the data parts.
Installation
pip install flit
pip install pyimporters-dummy
Publish the Python Package to PyPI
- Increment the version of your package in the
__init__.py
file:
"""An amazing package!"""
__version__ = 'x.y.z'
- Publish
flit publish
Write your own pyimporters plugin
- Git clone the pyimporters_dummy project
git clone git@bitbucket.org:kairntech/pyimporters_dummy.git
- Rename the project with your own format name <new_format>
mv pyimporters_dummy pyimporters_<new_format>
- Delete the .git directory
rm -r -f pyimporters_<new_format>/.git
- Change to the new pyimporters_<new_format> directory
cd pyimporters_<new_format>
- Rename the package directory project
mv pyimporters_dummy pyimporters_<new_format>
- Rename the python file implementation
mv pyimporters_<new_format>/dummy.py pyimporters_<new_format>/<new_format>.py
- Rename the python tests file implementation
mv tests/test_dummy.py tests/test_<new_format>.py
- Edit the pyproject.toml file to change a few lines and add your additional requirements
[tool.flit.metadata]
module = "pyimporters_<new_format>"
...
requires = [
"pyimporters_plugins>=0.1.61",
"additional_requirement1",
"additional_requirement2",
...
"additional_requirementN",
]
dist-name = "pyimporters-<new_format>"
...
[tool.flit.entrypoints."pyimporters.plugins"]
<new_format> = "pyimporters_<new_format>.<new_format>:NewFormatKnowledgeParser"
- Write the implementation and test of your new format in python using your favorite IDE
@dataclass
class NewFormatOptions(KnowledgeParserOptions):
"""
Options for the new format knowledge import
"""
foo : str = Query("bar", description="Dummy parameter")
NewFormatOptionsModel = NewFormatOptions.__pydantic_model__
class NewFormatKnowledgeParser(KnowledgeParserBase):
def parse(self, source : Path, options: Union[KnowledgeParserOptions, Dict[str, Any]], bar : Bar) -> Generator[Term, None, None]:
options = NewFormatOptions(**options) if isinstance(options, dict) else options
# Initialize the progress indicator number of terms to read so that the progress indicator can send feedback to the end user
bar.max = 100
bar.start()
# yield as many terms as you want, advancing the progress indicator each time
bar.next()
yield Term(identifier=options.foo, preferredForm=options.foo)
# Terminate the progress indicator
bar.finish()
@classmethod
def get_schema(cls) -> KnowledgeParserOptions:
return NewFormatOptions
@classmethod
def get_model(cls) -> Type[BaseModel]:
return NewFormatOptionsModel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyimporters-dummy-0.1.209.tar.gz
.
File metadata
- Download URL: pyimporters-dummy-0.1.209.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f48e2dbe3f951d4e3c3003a1a77493eb6e1b8b418c34b59348955674304229f0 |
|
MD5 | a74f44711de61ab4c86f4e01bcbce049 |
|
BLAKE2b-256 | f2d0b28c477df305cc211cd33116905a88c1e1f642284a74d90b5bc6418f6ac7 |
File details
Details for the file pyimporters_dummy-0.1.209-py3-none-any.whl
.
File metadata
- Download URL: pyimporters_dummy-0.1.209-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edd9654d107972a67dc171a1cf067d8263a0e02665a87020d198aa86ce6e90f9 |
|
MD5 | b6e703abbf70ce627da3bf054599c56c |
|
BLAKE2b-256 | 48565f4fec03f55bc6764fc7d936ea31b732ed379f34a47a432e5ad5208cbfad |