Skip to main content

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 test file implementation
mv test/test_dummy.py test/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"]
dummy = "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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyimporters-dummy-0.0.16.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

pyimporters_dummy-0.0.16-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file pyimporters-dummy-0.0.16.tar.gz.

File metadata

  • Download URL: pyimporters-dummy-0.0.16.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for pyimporters-dummy-0.0.16.tar.gz
Algorithm Hash digest
SHA256 c62d0f81344e73dc81ca60132165da22b44c2fcbe8e8d543690850a3e965ea71
MD5 6cd6ec2a516fc448748bb33eedf21d3c
BLAKE2b-256 da2ae4e24ff1df80a9bed58ada38addf3d7a32a31b924244a7861b16ed468141

See more details on using hashes here.

File details

Details for the file pyimporters_dummy-0.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for pyimporters_dummy-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 c6fac6f92d6374c4e2e4ccf5ae7971ce4997471310b0487b83a901cf5a5801dc
MD5 bb0a0b3b1ba8fdf65a6c630c28acc274
BLAKE2b-256 27002000fd3bc62972c259f28aca0f32e21c71993d2a57c3d0334e5727999a90

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page