pluginify 0.0.0.post1.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ """Cuboid data modifier plugin class.
2
+
3
+ This is a 'dummy' plugin which is strictly used for testing pluginify.
4
+ """
5
+
6
+ from pluginify.interfaces.class_based.data_modifiers import BaseDataModifierPlugin
7
+
8
+
9
+ class CuboidDataModifierPlugin(BaseDataModifierPlugin):
10
+ """Cuboid data modifier class.
11
+
12
+ This is a 'dummy' plugin which is strictly used for testing pluginify.
13
+ """
14
+
15
+ name = "cuboid"
16
+ interface = "data_modifiers"
17
+ family = "standard"
18
+
19
+ def call(self, data, config):
20
+ """Modify the cuboid-like dataset using parameters from 'config'.
21
+
22
+ Parameters
23
+ ----------
24
+ data: xarray.Dataset
25
+ - The incoming xarray.Dataset to modify.
26
+ config: dict
27
+ - A dictionary representing the configuration plugin used to modify this
28
+ dataset.
29
+
30
+ Returns
31
+ -------
32
+ xarray.Dataset
33
+ - The modified dataset based on the parameters set in 'config'.
34
+ """
35
+ for md_key, md_val in config["spec"].items():
36
+ data[md_key] = md_val
37
+
38
+ return data
39
+
40
+
41
+ PLUGIN_CLASS = CuboidDataModifierPlugin
@@ -0,0 +1,16 @@
1
+ apiVersion: pluginify/v1
2
+ interface: configs
3
+ name: stucco
4
+ family: standard
5
+ docstring: |
6
+ Configuration plugin containing parameters needed to create a stucco product.
7
+
8
+ This is a 'dummy' plugin which is strictly used for testing pluginify.
9
+ spec:
10
+ material: stucco
11
+ units: feet
12
+ dimensions:
13
+ height: 22
14
+ width: 36
15
+ depth: 18
16
+ shape: cuboid
@@ -0,0 +1,58 @@
1
+ """
2
+ Pydantic model for pluginify configuration plugins.
3
+
4
+ NOTE: these plugins are not intended to be used. They are just provided as an example to
5
+ see how the plugin registry functions and for testing this package.
6
+ """
7
+
8
+ from typing import Literal, Optional, Union
9
+
10
+ from pydantic import BaseModel, Field
11
+
12
+
13
+ class Dimensions(BaseModel):
14
+ """Model representing the dimensions field of a configuration plugin."""
15
+
16
+ y: Union[float, int] = Field(
17
+ ..., description="The height of the product.", alias="height"
18
+ )
19
+ x: Union[float, int] = Field(
20
+ ..., description="The width of the product.", alias="width"
21
+ )
22
+ z: Optional[Union[float, int]] = Field(
23
+ None, description="The depth of the product.", alias="depth"
24
+ )
25
+
26
+
27
+ class ConfigSpec(BaseModel):
28
+ """Model for the spec of a configuration plugin."""
29
+
30
+ material: str = Field(..., description="The material of the product.")
31
+ units: Literal["inches", "centimeters", "feet", "meters", "kilometers", "miles"] = (
32
+ Field(..., description="The units of the product.")
33
+ )
34
+ dimensions: Dimensions = Field(..., description="The dimensions of the product.")
35
+ shape: str = Field(..., description="The shape of the product.")
36
+
37
+
38
+ class ConfigPluginModel(BaseModel):
39
+ """Model for yaml configuration plugins.
40
+
41
+ Config plugins and all fields in those plugins are 'dummy' and strictly used for
42
+ testing purposes. For examples of real plugins which actually act upon data, see
43
+ https://github.com/NRLMMD-GEOIPS/geoips/tree/main/geoips/plugins.
44
+ """
45
+
46
+ apiVersion: str = Field(
47
+ "pluginify/v1",
48
+ description="The api version in which the plugin was implemented under.",
49
+ )
50
+ interface: str = Field(
51
+ ..., description="The interface which this plugin adheres to."
52
+ )
53
+ name: str = Field(..., description="The name of the plugin.")
54
+ family: str = Field(..., description="The family of the plugin.")
55
+ docstring: str = Field(
56
+ ..., description="A description of the plugin and what it does."
57
+ )
58
+ spec: ConfigSpec = Field(..., description="Specification of the product.")
@@ -0,0 +1,62 @@
1
+ # # # This source code is subject to the license referenced at
2
+ # # # https://github.com/NRLMMD-GEOIPS.
3
+
4
+ """Pluginify utility module."""
5
+
6
+ from copy import deepcopy
7
+
8
+
9
+ def merge_nested_dicts(dest, src, in_place=True, replace=False):
10
+ """Perform an in-place merge of src into dest.
11
+
12
+ Performs an in-place merge of src into dest while preserving any values that already
13
+ exist in dest.
14
+
15
+ Parameters
16
+ ----------
17
+ dest: dict
18
+ - The destination dictionary to merge to
19
+ src: dict
20
+ - The source dictionary to merge into dest
21
+ in_place: bool, default=True
22
+ - Whether or not to merge directly into dest or to create a deepcopy of dest
23
+ and return that as the final result. By default, this function will merge
24
+ directly into dest.
25
+ replace: boo, default=False
26
+ - Whether or not to override duplicate keys in src and dest with the contents of
27
+ src. By default, replace is set to false and overriding will not occur.
28
+ """
29
+ if not in_place:
30
+ final_dest = deepcopy(dest)
31
+ else:
32
+ final_dest = dest
33
+
34
+ # It will automatically replace ALL fields found in
35
+ # the original product spec and also found in the
36
+ # override with what is specified in the override
37
+ # in its entirety, without merging. This is not
38
+ # terribly useful overall - we probably want this
39
+ # sort of capability in the end, but more flexible
40
+ # and able to be applied to only specific fields,
41
+ # etc. This is a brute force method to at least
42
+ # allow overriding entire fields.
43
+ if replace:
44
+ for key in final_dest:
45
+ if key in src:
46
+ final_dest[key] = src[key]
47
+ return final_dest
48
+
49
+ try:
50
+ final_dest.update(src | final_dest)
51
+ except (AttributeError, TypeError):
52
+ return
53
+ try:
54
+ for key, val in final_dest.items(): # NOQA
55
+ try:
56
+ merge_nested_dicts(final_dest[key], src[key])
57
+ except KeyError:
58
+ pass
59
+ except AttributeError:
60
+ raise
61
+ if not in_place:
62
+ return final_dest
@@ -0,0 +1,32 @@
1
+ # # # This source code is subject to the license referenced at
2
+ # # # https://github.com/NRLMMD-GEOIPS.
3
+
4
+ """Module for handling optional dependencies throughout pluginify."""
5
+
6
+ import logging
7
+ from contextlib import contextmanager
8
+ import traceback
9
+
10
+ LOG = logging.getLogger(__name__)
11
+
12
+
13
+ @contextmanager
14
+ def import_optional_dependencies(loglevel="info"):
15
+ """Attempt to import a package and log the event if the import fails.
16
+
17
+ Parameters
18
+ ----------
19
+ loglevel : str
20
+ Name of the log level to write to. May be any valid log level (e.g. debug, info,
21
+ etc.).
22
+ """
23
+ try:
24
+ yield None
25
+ except ImportError as err:
26
+ tb = traceback.extract_tb(err.__traceback__)
27
+ filename, lineno, _, _ = tb[-1]
28
+ err_str = f"Failed to import {err.name} at {filename}:{lineno}. "
29
+ err_str += "If you need it, install it."
30
+
31
+ getattr(LOG, loglevel)(err_str)
32
+ # print(err_str)
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: pluginify
3
+ Version: 0.0.0.post1.dev0
4
+ Summary: Pluginify package
5
+ License: LICENSE
6
+ License-File: LICENSE
7
+ Author: Evan Rose
8
+ Requires-Python: >=3.11.0,<3.13.0
9
+ Classifier: License :: Other/Proprietary License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Provides-Extra: doc
14
+ Requires-Dist: docstring_parser
15
+ Requires-Dist: jsonschema (>4.18.0)
16
+ Requires-Dist: lexeme-type
17
+ Requires-Dist: platformdirs
18
+ Requires-Dist: pydantic (>=2.10.0)
19
+ Requires-Dist: pyyaml
20
+ Requires-Dist: sphinxcontrib-typer ; extra == "doc"
21
+ Requires-Dist: typer
22
+ Project-URL: Repository, https://github.com/NRLMMD-GEOIPS/pluginify
23
+ Description-Content-Type: text/markdown
24
+
25
+ # # # This source code is subject to the license referenced at
26
+ # # # https://github.com/NRLMMD-GEOIPS.
27
+
28
+ Pluginify
29
+ =========
30
+
31
+ This repository contains everything necessary to fully register YAML and python classes
32
+ and/or modules as valid python plugin objects. A YAML-based plugin object essentially
33
+ acts as a configuration object for a class / module -based python plugin. The python
34
+ based plugins are then responsible for reading, manipulating, or outputting a dataset
35
+ in a certain format. For most python based plugins, we expect this dataset to be a valid
36
+ xarray.DataTree object.
37
+
38
+ No valid plugins should be stored in this package. Rather, this package contains all the
39
+ functionality to register, retrieve, and create your plugin objects via a unified
40
+ PluginRegistry class. This package can and is used alongside other packages such as
41
+ [GeoIPS](https://github.com/NRLMMD-GEOIPS/geoips) to handle their plugin-based
42
+ infrastructure.
43
+
44
+ Install pluginify package
45
+ -------------------------
46
+ Current status:
47
+ ```bash
48
+ git clone https://github.com/NRLMMD-GEOIPS/pluginify.git
49
+ # cd to pluginify's top level dir
50
+ pip install -e .
51
+ ```
52
+ In the future:
53
+ ```bash
54
+ pip install pluginify
55
+ ```
56
+
57
+ Use pluginify
58
+ -------------
59
+ ```bash
60
+ pluginify -h
61
+ # Top level commands without additional args
62
+ pluginify create
63
+ # OR
64
+ pluginify delete
65
+ ```
66
+
@@ -0,0 +1,22 @@
1
+ pluginify/__init__.py,sha256=NvdicJtfy-dZZ8tWjR74lDBHGV6rlaH8pAJ7UHyTTog,391
2
+ pluginify/_version.py,sha256=I_xg_zrKOMl6Y8jLXjH6TifTHdty9HEaI8c-DJniO18,237
3
+ pluginify/commandline_typer.py,sha256=v9r7oBnD39pFLBqhoUNefGEwyRFCzDKpiPa3cvXXzCk,8676
4
+ pluginify/config.py,sha256=co4HkXsOrA68M0PlRaUAhz5KMp5pa60ssb7DwLvUuxk,4894
5
+ pluginify/create_plugin_registries.py,sha256=9NGFRzyZIaF7Mj1BMbNLTbyRVtnZWjmwSnCL0qnra_0,48494
6
+ pluginify/errors.py,sha256=kkdipLfxvj8f-Pp53SD3RPnD9QS3samBLlQBjBskZP8,373
7
+ pluginify/interfaces/__init__.py,sha256=XcPl52V8oMihP7NoRs_NgbiIvqoL3A4YeyfTOp3NqBA,329
8
+ pluginify/interfaces/base.py,sha256=ubimAsOgAXCyhKhn40-a1HIfrjMPqHtKr4rBnwm645M,26724
9
+ pluginify/interfaces/class_based/data_modifiers.py,sha256=p-d80oywjo9Rr6txowr1BIlg08qeOm3dAMm_4JQ0iH8,1072
10
+ pluginify/interfaces/class_based_plugin.py,sha256=TMuJ2INaaFaUlxPX05L5r2gH3ISu1W_2qWllGA63oq4,8209
11
+ pluginify/interfaces/yaml_based/configs.py,sha256=3U_nKCm2mIVfA_cRl-VUmu8JrQQQ3u24eshH46a9GI0,808
12
+ pluginify/plugin_registry.py,sha256=yN8ooSHB7HfM31AQoeDUB7oJc87K7ZJHR_XllVr-bCM,40546
13
+ pluginify/plugins/classes/data_modifiers/cuboid.py,sha256=WyvhPrRptpSHtPqeOdF1oiHm6zFwHahsLwNvsMdmQEE,1107
14
+ pluginify/plugins/yaml/configs/stucco.yaml,sha256=OXLWzmmzxSAWs-MzSlmEa-OLGJzVJzrVQZwgGPL2jqE,376
15
+ pluginify/pydantic_models/v1/configs.py,sha256=As15amNtdFwAobufh0d6mDlF3mMS23ThwTKQy9q25bc,2122
16
+ pluginify/utils/__init__.py,sha256=gdy4E4yEI9lrHbWPeBn0Bspj7iz4z6r8BAjbmHf_hpM,2088
17
+ pluginify/utils/context_managers.py,sha256=1-bREbijNNc5PrqMIihKqxlxNaK-YZ3hj5XGpHiYmfw,926
18
+ pluginify-0.0.0.post1.dev0.dist-info/METADATA,sha256=YoQUcPZOkt58ozii6zhO33T9-N11vPIxl-uxXl1aWsU,2086
19
+ pluginify-0.0.0.post1.dev0.dist-info/WHEEL,sha256=Vz2fHgx6HFtSwhs8KvkHLqH5Ea4w1_rner5uNVGCeIE,88
20
+ pluginify-0.0.0.post1.dev0.dist-info/entry_points.txt,sha256=kCm7HOEEzSnPyDpy98W-LYYmlLYyTnRqOj40UqxX6-w,111
21
+ pluginify-0.0.0.post1.dev0.dist-info/licenses/LICENSE,sha256=sIBqTiU78gw5bC9MZMySNxzCE7DIlOcDqUWdmflkDsY,7266
22
+ pluginify-0.0.0.post1.dev0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.3.2
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,6 @@
1
+ [console_scripts]
2
+ pluginify=pluginify.commandline_typer:main
3
+
4
+ [pluginify.plugin_packages]
5
+ pluginify=pluginify
6
+
@@ -0,0 +1,128 @@
1
+ NRL OPEN LICENSE AGREEMENT
2
+
3
+ 1. Scope and Applicability: This Agreement applies to Computer Software that
4
+ is made available under this Agreement. By using, modifying, or disseminating
5
+ the Computer Software, You accept the terms and conditions in this Agreement.
6
+ Use, modification, and dissemination of the Computer Software is permitted
7
+ only in accordance with the terms and conditions of this Agreement. No other
8
+ rights or licenses to the Computer Software are granted. Unauthorized use,
9
+ sale, conveyance, disposition, or modification of a Computer Software may
10
+ result in civil penalties and/or criminal penalties under 18 U.S.C. § 641.
11
+
12
+
13
+ 2. For purposes of this Agreement, the following definitions apply:
14
+
15
+ a. “Computer software” means computer programs, source code, source code
16
+ listings, object code listings, design details, algorithms, processes,
17
+ flow charts, formulae, and related material that would enable the software
18
+ to be reproduced, recreated, or recompiled.
19
+
20
+ b. “Derivative work” is a work based upon some or all of the Computer Software.
21
+
22
+ c. “Unlimited rights” means rights to use, modify, reproduce, release,
23
+ perform, display, or disclose, in whole or in part, in any manner and for
24
+ any purpose whatsoever, and to have or authorize others to do so.
25
+
26
+ d. “You” means yourself and any corporation, company, association, firm,
27
+ partnership, society, and joint stock company to which you are an employee,
28
+ volunteer, or an independent contractor performing services therefor.
29
+
30
+ 3. Use and Distribution License: The Government of the United States of
31
+ America (“Government”) hereby authorizes You to use and modify the Computer
32
+ Software for any purpose. The Government hereby authorizes You to
33
+ redistribute the Computer Software, but only under the terms of this
34
+ Agreement. You agree that any modifications to and derivative works of the
35
+ Computer Software generated by You shall be distributed only under the terms
36
+ of this Agreement. You shall provide a copy of this Agreement with any
37
+ distribution of the Computer Software, or any modification to and derivative
38
+ works of the Computer Software.
39
+
40
+ 4. Ownership: All Computer Software is property of the Government and under
41
+ the custody and administration of the U.S. Naval Research Laboratory (NRL).
42
+ Nothing in the Agreement shall be construed to constitute a sale, assignment,
43
+ or transfer of ownership to You of the Computer Software.
44
+
45
+ 5. Markings: You shall not remove any copyright notices, disclaimers, notices
46
+ of Government sponsorship and license rights, third-party licenses, and any
47
+ other identifications, contained in the Computer Software or provided in a
48
+ file accompanying the Computer Software, such as a license file.
49
+
50
+ 6. Header File Required: For source code provided under this Agreement, the
51
+ header of each source file shall contain the following statement:
52
+
53
+ !#######################################################################
54
+
55
+ THIS SOURCE CODE IS PROPERTY OF THE GOVERNMENT OF THE UNITED STATES OF
56
+ AMERICA. BY USING, MODIFYING, OR DISSEMINATING THIS SOURCE CODE, YOU ACCEPT
57
+ THE TERMS AND CONDITIONS IN THE NRL OPEN LICENSE AGREEMENT. USE, MODIFICATION,
58
+ AND DISSEMINATION ARE PERMITTED ONLY IN ACCORDANCE WITH THE TERMS AND
59
+ CONDITIONS OF THE NRL OPEN LICENSE AGREEMENT. NO OTHER RIGHTS OR LICENSES
60
+ ARE GRANTED. UNAUTHORIZED USE, SALE, CONVEYANCE, DISPOSITION, OR MODIFICATION
61
+ OF THIS SOURCE CODE MAY RESULT IN CIVIL PENALTIES AND/OR CRIMINAL PENALTIES
62
+ UNDER 18 U.S.C. § 641.
63
+
64
+ !########################################################################
65
+
66
+ 7. Government Rights: In consideration of making the Computer Software
67
+ available to You, You irrevocably grant the Government, at no cost, unlimited
68
+ rights in any and all modifications to, and derivative works of, the Computer
69
+ Software. Upon request, You shall deliver to NRL, or another Federal component
70
+ or agency as NRL may designate, all modifications to and derivative works of
71
+ the Computer Software generated by You or that are in Your possession.
72
+
73
+ 8. ALL MATERIAL IS PROVIDED “AS IS” AND WITHOUT ANY REPRESENTATION OR
74
+ WARRANTY, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY PARTICULAR PURPOSE
75
+ OR ANY WARRANTIES OF ACCURACY OR COMPLETENESS OR ANY WARRANTIES THAT THE
76
+ USE OF THE COMPUTER SOFTWARE WILL NOT INFRINGE OR VIOLATE ANY PATENT OR
77
+ OTHER PROPRIETARY RIGHTS OF ANY THIRD PARTY (WHETHER DIRECTLY OR INDIRECTLY).
78
+
79
+ 9. Notice: You shall provide prominent notice on any derivative work of the
80
+ Computer Software, or in a file accompanying the Computer Software, that the
81
+ Computer Software was developed in part or in whole by NRL.
82
+
83
+ 10. No Support. The Computer Software(s) is provided without any support or
84
+ maintenance, and without any obligation to provide modifications,
85
+ improvements, enhancements, or updates thereto. No oral or written
86
+ information or advice given by Federal employees shall create a warranty
87
+ or in any way modify this Agreement.
88
+
89
+ 11. Export Control: This Agreement does not authorize any disclosure, export,
90
+ or deemed export of technical information, articles, or services, nor does it
91
+ authorize or approve the use of any exemption to the export licensing
92
+ requirements of the International Traffic in Arms Regulations (“ITAR”) or the
93
+ Export Administration Regulations (“EAR”). You shall ensure full compliance
94
+ with all applicable requirements and restrictions established in law and
95
+ regulation pertaining to United States export controls including the Arms
96
+ Export Control Act, the International Traffic in Arms Regulations, the Export
97
+ Control Reform Act, the Export Administration Regulations, and the Atomic
98
+ Energy Act.
99
+
100
+ 12. Termination: The Government, either through NRL or another Federal
101
+ component or agency, may terminate this Agreement at any time. The Government
102
+ rights under Section 7 shall survive termination.
103
+
104
+ 13. Liability: You shall be solely liable for all claims and/or damages which
105
+ may arise from Your use, storage or disposal of the Computer Software under
106
+ this Agreement. Nothing in this Agreement shall be construed as a waiver of
107
+ the sovereign immunity of the United States.
108
+
109
+ 14. Indemnification: You agree on behalf of Yourself, and any successors in
110
+ interest or assignees of You, to hold harmless and indemnify the United States
111
+ from any claim for damages or injury to any person or property arising out of
112
+ the provision of the Computer Software. This will include any costs relating
113
+ to infringing a third party’s intellectual property rights.
114
+
115
+ 15. Governing Law & Jurisdiction. If a dispute, controversy, or claim relating
116
+ to this Agreement shall arise, You agree to first attempt to settle such
117
+ matter through informal dispute resolution. If any such matter cannot be
118
+ resolved informally, applicable U.S. Federal laws shall govern this Agreement
119
+ for all purposes.
120
+
121
+ 16. No Government Endorsement: You shall not make or include any statements
122
+ that imply NRL or another component or agency of the Federal Government
123
+ endorses You, Your work, or any product or service You offer.
124
+
125
+ 17. Severability. If any provision or term of this Agreement is held to be
126
+ invalid by a court of competent jurisdiction, then such provision or term
127
+ will be enforced to the maximum extent possible and the remaining terms of
128
+ this Agreement will continue in full force and effect.