Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@

This package provides an API to write and execute scripts in a running ZEISS INSPECT instance.
Please read the [ZEISS INSPECT API documentation](https://zeiss.github.io/IQS/) for details.

The [ZEISS INSPECT API wheel](https://pypi.org/project/zeiss-inspect-api/) is hosted on PyPI.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add this to README.md?

46 changes: 23 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "zeiss_inspect_api"
version = "2026.1.0.359"
authors = [
{ name="Carl Zeiss GOM Metrology GmbH", email="info.optical.metrology@zeiss.com" },
]
description = "ZEISS INSPECT API"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"websocket-client"
]
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]

[project.urls]
"Homepage" = "https://github.com/ZEISS/zeiss-inspect-api-wheel"
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "zeiss_inspect_api"
version = "2026.3.0.342"
authors = [
{ name="Carl Zeiss GOM Metrology GmbH", email="info.optical.metrology@zeiss.com" },
]
description = "ZEISS INSPECT API"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"websocket-client"
]
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
[project.urls]
"Homepage" = "https://github.com/ZEISS/zeiss-inspect-api-wheel"
23 changes: 16 additions & 7 deletions src/gom/__api__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,14 @@ def __instance_creator__(self, obj):
#
return GomApiInstance(obj['id'])

def encode(self, req):
def encode(self, req, caller):
from gom.__network__ import EncoderContext, DecoderContext

with EncoderContext() as context:
string = json.dumps(req, cls=Encoder.CustomJSONEncoder, encoding_context=context)

string = gom.__common__.__connection__.request(Request.API, {'json': string})
string = gom.__common__.__connection__.request(
Request.API, {'json': string, 'caller': caller if caller != None else ""})

with DecoderContext() as context:
reply = json.loads(string, cls=Encoder.CustomJSONDecoder, decoding_context=context)
Expand All @@ -399,7 +400,7 @@ def encode(self, req):
return reply['result']
raise KeyError()

def call_function(self, module, function, args, kwargs):
def call_function(self, module, function, args, kwargs={}, caller=None):

#
# Script-to-script call shortlink. This way, various value conversions can be skipped and shared memory for
Expand All @@ -414,16 +415,16 @@ def call_function(self, module, function, args, kwargs):
'params': args
}

return self.encode(request)
return self.encode(request, caller)

def call_method(self, instance, method, args):
def call_method(self, instance, method, args, caller=None):
request = {
'instance': instance,
'call': method,
'params': args
}

return self.encode(request)
return self.encode(request, caller)


__encoder__ = Encoder()
Expand All @@ -437,12 +438,20 @@ def __call_function__(*args, **kwargs):
'''
frame = inspect.currentframe().f_back

# Extract the original function caller, i.e., the script in which the api function was written
# The distinction to the executed script is important for some api functions in the context of shared environments
# There scripts from other apps can be imported and some api functions resolve the calls based on the app (e.g. settings)
parent = frame.f_back
caller = ""
if parent != None:
caller = parent.f_code.co_filename

module = inspect.getmodule(frame).__name__
prefix = 'gom.api.'
if module.startswith(prefix):
module = module[len(prefix):]

return __encoder__.call_function(module, frame.f_code.co_name, args, kwargs)
return __encoder__.call_function(module, frame.f_code.co_name, args, kwargs, caller)


class Object:
Expand Down
1 change: 0 additions & 1 deletion src/gom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

import gom.__api__
import gom.__config__
import gom.__state__
import gom.__test__
import gom.__tools__

Expand Down
5 changes: 2 additions & 3 deletions src/gom/__network__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#

import inspect
import pickle
import threading
import traceback
Expand Down Expand Up @@ -151,8 +150,8 @@ def request(self, command, params):
'''
Send request and wait for incoming replies or calls

This function sends a request to the server and waits until a new message comes in.
That message can either be the reply to the request sent or a new client site function
This function sends a request to the server and waits until a new message comes in.
That message can either be the reply to the request sent or a new client site function
call. The function does not return before the request has been answered.
'''
if not isinstance(command, Request):
Expand Down
11 changes: 9 additions & 2 deletions src/gom/__tools__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,22 @@ def filter_exception_traceback(tb):
# Traceback frames originating from the 'gom' system module are completely skipped.
# The temporary directory information is removed from the traceback file paths.
#
# <string> entries at the start of the stacktrace are removed as well, these originate from the in-memory startup-script
#
filtered = []
at_stacktrace_start = True
for frame, line in traceback.walk_tb(tb):
if not gom.__config__.strip_tracebacks:
filtered.append((frame, line))
elif at_stacktrace_start and frame.f_code.co_filename == "<string>":
continue
elif not os.path.realpath(frame.f_code.co_filename).startswith(system_frame_prefix):
if not '\\importlib\\' in frame.f_code.co_filename:
if not 'frozen importlib' in frame.f_code.co_filename:
if str(frame.f_code.co_filename) != executed_file_prefix + '__gom_run_script__.py':
filtered.append((frame, line))
filtered.append((frame, line))
# Once we encounter anything but a to be filtered "<string>" entry,
# we do not filter any other of this type from the middle of the stacktrace
at_stacktrace_start = False

return ''.join(traceback.StackSummary.extract(
filtered).format()).replace(executed_file_prefix, '')
Expand Down
2 changes: 1 addition & 1 deletion src/gom/__types__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def type_getattribute(self, key):
@staticmethod
def type_setattr(self, key, value):

if key in self.__args__:
if key in self.__kwargs__:
self.__kwargs__[key] = value

gom.__common__.__connection__.request(Request.TYPE_SETATTR, {'type': type(self).__id__,
Expand Down
28 changes: 0 additions & 28 deletions src/gom/api/__init__.py

This file was deleted.

150 changes: 75 additions & 75 deletions src/gom/api/__internal__progress/__init__.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
#
# API declarations for gom.api.__internal__progress
#
# @nodoc
#
# @brief Internal API for accessing the progress bar in the main window
#

import gom
import gom.__api__

from typing import Any
from uuid import UUID

class InternalProgressBar (gom.__api__.Object):
'''
@nodoc

@brief Class representing the internal ProgressBar
'''

def __init__ (self, instance_id):
super ().__init__ (instance_id)

def _register_watcher(self) -> None:
'''
@nodoc

@brief Only for internal use!
'''
return self.__call_method__('_register_watcher')

def _deregister_watcher(self) -> None:
'''
@nodoc

@brief Only for internal use!
'''
return self.__call_method__('_deregister_watcher')

def _set_progress(self, progress:int) -> None:
'''
@nodoc

@brief Sets the progress in the main window progress bar
@version 1

@param progress in percent, given as an integer from 0 to 100
@return nothing
'''
return self.__call_method__('_set_progress', progress)

def _set_message(self, message:str) -> None:
'''
@nodoc

@brief Sets a message in the main window progress bar
@version 1

@param message the message to display
@return nothing
'''
return self.__call_method__('_set_message', message)


def _create_internal_progress_bar(passcode:str) -> None:
'''
gom.api.__internal__progress.InternalProgressBar

@nodoc

@brief Only for internal use!
'''
return gom.__api__.__call_function__(passcode)

#
# API declarations for gom.api.__internal__progress
#
# @nodoc
#
# @brief Internal API for accessing the progress bar in the main window
#
import gom
import gom.__api__
from typing import Any
from uuid import UUID
class InternalProgressBar (gom.__api__.Object):
'''
@nodoc
@brief Class representing the internal ProgressBar
'''
def __init__ (self, instance_id):
super ().__init__ (instance_id)
def _register_watcher(self) -> None:
'''
@nodoc
@brief Only for internal use!
'''
return self.__call_method__('_register_watcher')
def _deregister_watcher(self) -> None:
'''
@nodoc
@brief Only for internal use!
'''
return self.__call_method__('_deregister_watcher')
def _set_progress(self, progress:int) -> None:
'''
@nodoc
@brief Sets the progress in the main window progress bar
@version 1
@param progress in percent, given as an integer from 0 to 100
@return nothing
'''
return self.__call_method__('_set_progress', progress)
def _set_message(self, message:str) -> None:
'''
@nodoc
@brief Sets a message in the main window progress bar
@version 1
@param message the message to display
@return nothing
'''
return self.__call_method__('_set_message', message)
def _create_internal_progress_bar(passcode:str) -> None:
'''
gom.api.__internal__progress.InternalProgressBar
@nodoc
@brief Only for internal use!
'''
return gom.__api__.__call_function__(passcode)
Loading