Skip to content

feat(system): add config submodule#56

Merged
cesarcoatl merged 2 commits into
8.3from
feat/system/config
Jul 17, 2026
Merged

feat(system): add config submodule#56
cesarcoatl merged 2 commits into
8.3from
feat/system/config

Conversation

@cesarcoatl

@cesarcoatl cesarcoatl commented Jul 17, 2026

Copy link
Copy Markdown
Member

Closes: #54

Summary by Sourcery

Introduce a system.config API for managing Gateway resources, backed by a PyResource abstraction, and update documentation to reference the latest Jython standalone version.

New Features:

  • Add a system.config module exposing functions to create, copy, move, rename, replace, delete, and query Gateway resources and deployment modes.
  • Add a PyResource class in the Ignition Gateway scripting package to represent Gateway resources and their metadata.

Enhancements:

  • Add type stub files for the system.config module and PyResource class to improve editor support and static type checking.

Documentation:

  • Update the README Jython documentation link to point to the 2.7.4 jython-standalone Javadoc.

@sourcery-ai

sourcery-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a new system.config scripting submodule backed by a PyResource wrapper, plus matching type stubs and a minor documentation link update.

File-Level Changes

Change Details Files
Introduce system.config scripting functions for Gateway resource management.
  • Add config submodule with functions to copy, create, delete, move, rename, replace, and query Gateway resources and deployment modes
  • Implement all functions as thin shims that print arguments and return placeholder PyResource objects or simple values
  • Export public API via all for the config module
src/system/config.py
Add PyResource wrapper class for Gateway resources and expose it in the scripting package namespace.
  • Define PyResource class extending org.python.core.PyObject with typed accessor methods for resource metadata, configuration, files, and state
  • Provide a minimal init implementation that prints the underlying resource and leaves methods unimplemented (pass)
  • Expose PyResource via all at the package level
src/com/inductiveautomation/ignition/gateway/script/__init__.py
Provide type stubs for the new system.config module and PyResource class to support static type checking and editor tooling.
  • Add config.pyi stub mirroring the system.config function signatures and return types
  • Add init.pyi stub defining the PyResource class interface and method signatures
  • Align stub types (Union[str, unicode], Optional, Mapping, List) with runtime module definitions
stubs/stubs/system/config.pyi
stubs/stubs/com/inductiveautomation/ignition/gateway/script/__init__.pyi
Update README to reference the latest Jython standalone documentation version.
  • Bump Jython javadoc link from version 2.7.3 to 2.7.4 in the README
README.md

Assessment against linked issues

Issue Objective Addressed Explanation
#54 Implement the system.config scripting submodule with the documented functions in the runtime code.
#54 Provide type stubs for the system.config submodule to support static analysis and autocomplete.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 5 issues, and left some high level feedback:

  • The config functions and PyResource.__init__ currently use print for debugging, which will be noisy for consumers of this API; consider removing these or switching to a configurable logging mechanism before this module is relied on in production.
  • Several docstrings appear to be copy/pasted or contain small inaccuracies (e.g., replace describes copying and mentions newName/newCollection, delete has force: f true), so tightening these up to reflect the actual semantics will make the API much clearer to users.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `config` functions and `PyResource.__init__` currently use `print` for debugging, which will be noisy for consumers of this API; consider removing these or switching to a configurable logging mechanism before this module is relied on in production.
- Several docstrings appear to be copy/pasted or contain small inaccuracies (e.g., `replace` describes copying and mentions `newName`/`newCollection`, `delete` has `force: f true`), so tightening these up to reflect the actual semantics will make the API much clearer to users.

## Individual Comments

### Comment 1
<location path="src/system/config.py" line_range="152-153" />
<code_context>
+        collection: The collection containing the resource. If omitted,
+            uses the active definition. Optional.
+        signature: The hex-encoded signature of the resource. Optional.
+        force: f true, deletes the resource even if other resources
+            reference it. If omitted, default is false. Optional.
+        actor: A string identifying the actor performing the operation.
</code_context>
<issue_to_address>
**nitpick (typo):** Fix the typo and capitalization in the `force` parameter description.

Update the `force` docstring to something like: `If true, deletes the resource even if other resources reference it. If omitted, the default is False.` This fixes the typo, clarifies behavior, and uses standard boolean capitalization.

```suggestion
        force: If true, deletes the resource even if other resources
            reference it. If omitted, the default is False. Optional.
```
</issue_to_address>

### Comment 2
<location path="src/system/config.py" line_range="314-41" />
<code_context>
+    return PyResource()
+
+
+def replace(
+    moduleId,  # type: Union[str, unicode]
+    typeId,  # type: Union[str, unicode]
+    name=None,  # type: Union[str, unicode, None]
+    collection=None,  # type: Union[str, unicode, None]
+    signature=None,  # type: Union[str, unicode, None]
+    config=None,  # type: Optional[Dict[Union[str, unicode], Any]]
+    backupConfig=None,  # type: Optional[Dict[Union[str, unicode], Any]]
+    files=None,  # type: Optional[Dict[Union[str, unicode], Any]]
+    description=None,  # type: Union[str, unicode, None]
+    enabled=None,  # type: Optional[bool]
+    attributes=None,  # type: Optional[Dict[Union[str, unicode], Any]]
+    actor=None,  # type: Union[str, unicode, None]
+):
+    # type: (...) -> PyResource
+    """Copies a resource to a new name and/or collection.
+
+    When using this function, either the newName or newCollection
+    parameter must be defined.
+
</code_context>
<issue_to_address>
**issue:** Update the `replace` docstring so it accurately describes a replace operation and matches the parameters.

The current docstring still describes a copy operation and references `newName`/`newCollection`, which aren’t parameters of this function. Please update it to describe the replace behavior and remove references to non-existent arguments so callers aren’t misled.
</issue_to_address>

### Comment 3
<location path="src/system/config.py" line_range="183-49" />
<code_context>
+    return []
+
+
+def getResource(
+    moduleId,  # type: Union[str, unicode]
+    typeId,  # type: Union[str, unicode]
+    name,  # type: Union[str, unicode]
+    collection,  # type: Union[str, unicode]
+):
+    # type: (...) -> PyResource
+    """Returns a resource from the Gateway.
+
+    Args:
+        moduleId: The module ID portion of the resource type identifier.
+        typeId: The type ID portion of the resource type identifier.
+        name: The name of the resource. Required for named resources,
+            but must be omitted for singleton resources.
+        collection: The collection containing the resource. If omitted,
+            uses the active definition.
+
</code_context>
<issue_to_address>
**question:** Consider reconciling the `getResource` docstring with the function signature regarding the `collection` argument.

The docstring says `collection` may be omitted, but the function requires it as a positional argument with no default. Either make `collection` optional with a default of `None` (and update the type hint) or update the docstring to state that `collection` is required.
</issue_to_address>

### Comment 4
<location path="src/system/config.py" line_range="116-125" />
<code_context>
+        your newly created Gateway resource, which can also be read as
+        plain Python properties.
+    """
+    print(
+        moduleId,
+        typeId,
+        name,
+        collection,
+        config,
+        backupConfig,
+        files,
+        description,
+        enabled,
+        attributes,
+        actor,
+    )
+    return PyResource()
</code_context>
<issue_to_address>
**suggestion:** Avoid unconditional `print` statements in library functions.

In `create` (and similar functions in this module), printing all arguments will generate unexpected console output for library consumers. Please either switch to a proper logging mechanism or remove these prints if they were only for debugging/stub behavior.

Suggested implementation:

```python
    Returns:
        A PyResource containing the specified parameter attributes of
        your newly created Gateway resource, which can also be read as
        plain Python properties.
    """


 def create(

```

```python
    return PyResource()

```

If similar debugging `print(...)` calls were added to other functions in this module (e.g., `update`, `delete`, etc.), they should be removed or replaced with calls to a configured logger (`logging.getLogger(__name__).debug(...)`) to avoid unexpected console output for library consumers.
</issue_to_address>

### Comment 5
<location path="src/system/config.py" line_range="227-229" />
<code_context>
+    return [PyResource()]
+
+
+def getResourceTypes():
+    # type: () -> List[Any]
+    """Returns a list of all registered resource types.
+
+    Returns:
</code_context>
<issue_to_address>
**suggestion:** Consider tightening the return type of `getResourceTypes` to reflect the documented tuple structure.

The docstring promises `a list of tuples containing all the currently registered resource types`, but the annotation is `List[Any]`. If that tuple structure is stable, please update the type to something like `List[Tuple[...]]` and keep the `.pyi` stub in sync so callers get accurate type information.

Suggested implementation:

```python
def getResourceTypes():
    # type: () -> List[Tuple[str, str]]
    """Returns a list of all registered resource types.

    Returns:

```

` since it’s not shown).

Here are the code changes:

<file_operations>
<file_operation operation="edit" file_path="src/system/config.py">
<<<<<<< SEARCH
def getResourceTypes():
    # type: () -> List[Any]
    """Returns a list of all registered resource types.

    Returns:
=======
def getResourceTypes():
    # type: () -> List[Tuple[str, str]]
    """Returns a list of all registered resource types.

    Returns:
>>>>>>> REPLACE
</file_operation>
</file_operations>

<additional_changes>
1. Ensure `Tuple` is imported from `typing` at the top of `src/system/config.py`, for example:

   <<<<<<< SEARCH
   from typing import Any, List
   =======
   from typing import Any, List, Tuple
   >>>>>>> REPLACE

   Adjust the SEARCH line to match the existing import(s) in your file.

2. Update the corresponding stub file (likely `src/system/config.pyi` or similar) so that the `getResourceTypes` signature uses the same tightened type:
   `def getResourceTypes() -> List[Tuple[str, str]]: ...`

3. If the tuple structure contains more or different fields than two `str` values, refine the `Tuple[...]` contents accordingly in both `.py` and `.pyi` files (e.g. `Tuple[str, str, int]` or a `TypedDict`/`NamedTuple` if appropriate).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/system/config.py
Comment on lines +152 to +153
force: f true, deletes the resource even if other resources
reference it. If omitted, default is false. Optional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Fix the typo and capitalization in the force parameter description.

Update the force docstring to something like: If true, deletes the resource even if other resources reference it. If omitted, the default is False. This fixes the typo, clarifies behavior, and uses standard boolean capitalization.

Suggested change
force: f true, deletes the resource even if other resources
reference it. If omitted, default is false. Optional.
force: If true, deletes the resource even if other resources
reference it. If omitted, the default is False. Optional.

Comment thread src/system/config.py
Comment thread src/system/config.py
typeId: The type ID portion of the resource type identifier.
name: The name of the resource. Required for named resources,
but must be omitted for singleton resources. Optional.
collection: The collection containing the resource. If omitted,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Consider reconciling the getResource docstring with the function signature regarding the collection argument.

The docstring says collection may be omitted, but the function requires it as a positional argument with no default. Either make collection optional with a default of None (and update the type hint) or update the docstring to state that collection is required.

Comment thread src/system/config.py
Comment on lines +116 to +125
print(
moduleId,
typeId,
name,
collection,
config,
backupConfig,
files,
description,
enabled,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid unconditional print statements in library functions.

In create (and similar functions in this module), printing all arguments will generate unexpected console output for library consumers. Please either switch to a proper logging mechanism or remove these prints if they were only for debugging/stub behavior.

Suggested implementation:

    Returns:
        A PyResource containing the specified parameter attributes of
        your newly created Gateway resource, which can also be read as
        plain Python properties.
    """


 def create(
    return PyResource()

If similar debugging print(...) calls were added to other functions in this module (e.g., update, delete, etc.), they should be removed or replaced with calls to a configured logger (logging.getLogger(__name__).debug(...)) to avoid unexpected console output for library consumers.

Comment thread src/system/config.py
Comment on lines +227 to +229
def getResourceTypes():
# type: () -> List[Any]
"""Returns a list of all registered resource types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider tightening the return type of getResourceTypes to reflect the documented tuple structure.

The docstring promises a list of tuples containing all the currently registered resource types, but the annotation is List[Any]. If that tuple structure is stable, please update the type to something like List[Tuple[...]] and keep the .pyi stub in sync so callers get accurate type information.

Suggested implementation:

def getResourceTypes():
    # type: () -> List[Tuple[str, str]]
    """Returns a list of all registered resource types.

    Returns:

` since it’s not shown).

Here are the code changes:

<file_operations>
<file_operation operation="edit" file_path="src/system/config.py">
<<<<<<< SEARCH
def getResourceTypes():
# type: () -> List[Any]
"""Returns a list of all registered resource types.

Returns:

=======
def getResourceTypes():
# type: () -> List[Tuple[str, str]]
"""Returns a list of all registered resource types.

Returns:

REPLACE
</file_operation>
</file_operations>

<additional_changes>

  1. Ensure Tuple is imported from typing at the top of src/system/config.py, for example:

    <<<<<<< SEARCH
    from typing import Any, List

    from typing import Any, List, Tuple

    REPLACE

    Adjust the SEARCH line to match the existing import(s) in your file.

  2. Update the corresponding stub file (likely src/system/config.pyi or similar) so that the getResourceTypes signature uses the same tightened type:
    def getResourceTypes() -> List[Tuple[str, str]]: ...

  3. If the tuple structure contains more or different fields than two str values, refine the Tuple[...] contents accordingly in both .py and .pyi files (e.g. Tuple[str, str, int] or a TypedDict/NamedTuple if appropriate).

@cesarcoatl
cesarcoatl merged commit 6642b32 into 8.3 Jul 17, 2026
5 checks passed
@cesarcoatl
cesarcoatl deleted the feat/system/config branch July 17, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 8.3.8 scripting functions - system.config

1 participant