Skip to content

Commit 27a91b6

Browse files
authored
Merge pull request #16 from ZEISS/apiwheel-update-main
Python API wheel update pull request (main)
2 parents 71ee81c + 9d373a9 commit 27a91b6

File tree

30 files changed

+3148
-2009
lines changed

30 files changed

+3148
-2009
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22

33
This package provides an API to write and execute scripts in a running ZEISS INSPECT instance.
44
Please read the [ZEISS INSPECT API documentation](https://zeiss.github.io/IQS/) for details.
5-
6-
The [ZEISS INSPECT API wheel](https://pypi.org/project/zeiss-inspect-api/) is hosted on PyPI.

pyproject.toml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
[build-system]
2-
requires = ["setuptools>=61.0"]
3-
build-backend = "setuptools.build_meta"
4-
5-
[project]
6-
name = "zeiss_inspect_api"
7-
version = "2026.1.0.359"
8-
authors = [
9-
{ name="Carl Zeiss GOM Metrology GmbH", email="info.optical.metrology@zeiss.com" },
10-
]
11-
description = "ZEISS INSPECT API"
12-
readme = "README.md"
13-
requires-python = ">=3.9"
14-
dependencies = [
15-
"websocket-client"
16-
]
17-
classifiers = [
18-
"Programming Language :: Python :: 3",
19-
"Operating System :: OS Independent",
20-
]
21-
22-
[project.urls]
23-
"Homepage" = "https://github.com/ZEISS/zeiss-inspect-api-wheel"
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "zeiss_inspect_api"
7+
version = "2026.3.0.342"
8+
authors = [
9+
{ name="Carl Zeiss GOM Metrology GmbH", email="info.optical.metrology@zeiss.com" },
10+
]
11+
description = "ZEISS INSPECT API"
12+
readme = "README.md"
13+
requires-python = ">=3.9"
14+
dependencies = [
15+
"websocket-client"
16+
]
17+
classifiers = [
18+
"Programming Language :: Python :: 3",
19+
"Operating System :: OS Independent",
20+
]
21+
22+
[project.urls]
23+
"Homepage" = "https://github.com/ZEISS/zeiss-inspect-api-wheel"

src/gom/__api__.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,14 @@ def __instance_creator__(self, obj):
382382
#
383383
return GomApiInstance(obj['id'])
384384

385-
def encode(self, req):
385+
def encode(self, req, caller):
386386
from gom.__network__ import EncoderContext, DecoderContext
387387

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

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

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

402-
def call_function(self, module, function, args, kwargs):
403+
def call_function(self, module, function, args, kwargs={}, caller=None):
403404

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

417-
return self.encode(request)
418+
return self.encode(request, caller)
418419

419-
def call_method(self, instance, method, args):
420+
def call_method(self, instance, method, args, caller=None):
420421
request = {
421422
'instance': instance,
422423
'call': method,
423424
'params': args
424425
}
425426

426-
return self.encode(request)
427+
return self.encode(request, caller)
427428

428429

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

441+
# Extract the original function caller, i.e., the script in which the api function was written
442+
# The distinction to the executed script is important for some api functions in the context of shared environments
443+
# There scripts from other apps can be imported and some api functions resolve the calls based on the app (e.g. settings)
444+
parent = frame.f_back
445+
caller = ""
446+
if parent != None:
447+
caller = parent.f_code.co_filename
448+
440449
module = inspect.getmodule(frame).__name__
441450
prefix = 'gom.api.'
442451
if module.startswith(prefix):
443452
module = module[len(prefix):]
444453

445-
return __encoder__.call_function(module, frame.f_code.co_name, args, kwargs)
454+
return __encoder__.call_function(module, frame.f_code.co_name, args, kwargs, caller)
446455

447456

448457
class Object:

src/gom/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
import gom.__api__
5050
import gom.__config__
51-
import gom.__state__
5251
import gom.__test__
5352
import gom.__tools__
5453

src/gom/__network__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
# POSSIBILITY OF SUCH DAMAGE.
2828
#
2929

30-
import inspect
3130
import pickle
3231
import threading
3332
import traceback
@@ -151,8 +150,8 @@ def request(self, command, params):
151150
'''
152151
Send request and wait for incoming replies or calls
153152
154-
This function sends a request to the server and waits until a new message comes in.
155-
That message can either be the reply to the request sent or a new client site function
153+
This function sends a request to the server and waits until a new message comes in.
154+
That message can either be the reply to the request sent or a new client site function
156155
call. The function does not return before the request has been answered.
157156
'''
158157
if not isinstance(command, Request):

src/gom/__tools__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,22 @@ def filter_exception_traceback(tb):
7171
# Traceback frames originating from the 'gom' system module are completely skipped.
7272
# The temporary directory information is removed from the traceback file paths.
7373
#
74+
# <string> entries at the start of the stacktrace are removed as well, these originate from the in-memory startup-script
75+
#
7476
filtered = []
77+
at_stacktrace_start = True
7578
for frame, line in traceback.walk_tb(tb):
7679
if not gom.__config__.strip_tracebacks:
7780
filtered.append((frame, line))
81+
elif at_stacktrace_start and frame.f_code.co_filename == "<string>":
82+
continue
7883
elif not os.path.realpath(frame.f_code.co_filename).startswith(system_frame_prefix):
7984
if not '\\importlib\\' in frame.f_code.co_filename:
8085
if not 'frozen importlib' in frame.f_code.co_filename:
81-
if str(frame.f_code.co_filename) != executed_file_prefix + '__gom_run_script__.py':
82-
filtered.append((frame, line))
86+
filtered.append((frame, line))
87+
# Once we encounter anything but a to be filtered "<string>" entry,
88+
# we do not filter any other of this type from the middle of the stacktrace
89+
at_stacktrace_start = False
8390

8491
return ''.join(traceback.StackSummary.extract(
8592
filtered).format()).replace(executed_file_prefix, '')

src/gom/__types__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def type_getattribute(self, key):
124124
@staticmethod
125125
def type_setattr(self, key, value):
126126

127-
if key in self.__args__:
127+
if key in self.__kwargs__:
128128
self.__kwargs__[key] = value
129129

130130
gom.__common__.__connection__.request(Request.TYPE_SETATTR, {'type': type(self).__id__,

src/gom/api/__init__.py

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
#
2-
# API declarations for gom.api.__internal__progress
3-
#
4-
# @nodoc
5-
#
6-
# @brief Internal API for accessing the progress bar in the main window
7-
#
8-
9-
import gom
10-
import gom.__api__
11-
12-
from typing import Any
13-
from uuid import UUID
14-
15-
class InternalProgressBar (gom.__api__.Object):
16-
'''
17-
@nodoc
18-
19-
@brief Class representing the internal ProgressBar
20-
'''
21-
22-
def __init__ (self, instance_id):
23-
super ().__init__ (instance_id)
24-
25-
def _register_watcher(self) -> None:
26-
'''
27-
@nodoc
28-
29-
@brief Only for internal use!
30-
'''
31-
return self.__call_method__('_register_watcher')
32-
33-
def _deregister_watcher(self) -> None:
34-
'''
35-
@nodoc
36-
37-
@brief Only for internal use!
38-
'''
39-
return self.__call_method__('_deregister_watcher')
40-
41-
def _set_progress(self, progress:int) -> None:
42-
'''
43-
@nodoc
44-
45-
@brief Sets the progress in the main window progress bar
46-
@version 1
47-
48-
@param progress in percent, given as an integer from 0 to 100
49-
@return nothing
50-
'''
51-
return self.__call_method__('_set_progress', progress)
52-
53-
def _set_message(self, message:str) -> None:
54-
'''
55-
@nodoc
56-
57-
@brief Sets a message in the main window progress bar
58-
@version 1
59-
60-
@param message the message to display
61-
@return nothing
62-
'''
63-
return self.__call_method__('_set_message', message)
64-
65-
66-
def _create_internal_progress_bar(passcode:str) -> None:
67-
'''
68-
gom.api.__internal__progress.InternalProgressBar
69-
70-
@nodoc
71-
72-
@brief Only for internal use!
73-
'''
74-
return gom.__api__.__call_function__(passcode)
75-
1+
#
2+
# API declarations for gom.api.__internal__progress
3+
#
4+
# @nodoc
5+
#
6+
# @brief Internal API for accessing the progress bar in the main window
7+
#
8+
9+
import gom
10+
import gom.__api__
11+
12+
from typing import Any
13+
from uuid import UUID
14+
15+
class InternalProgressBar (gom.__api__.Object):
16+
'''
17+
@nodoc
18+
19+
@brief Class representing the internal ProgressBar
20+
'''
21+
22+
def __init__ (self, instance_id):
23+
super ().__init__ (instance_id)
24+
25+
def _register_watcher(self) -> None:
26+
'''
27+
@nodoc
28+
29+
@brief Only for internal use!
30+
'''
31+
return self.__call_method__('_register_watcher')
32+
33+
def _deregister_watcher(self) -> None:
34+
'''
35+
@nodoc
36+
37+
@brief Only for internal use!
38+
'''
39+
return self.__call_method__('_deregister_watcher')
40+
41+
def _set_progress(self, progress:int) -> None:
42+
'''
43+
@nodoc
44+
45+
@brief Sets the progress in the main window progress bar
46+
@version 1
47+
48+
@param progress in percent, given as an integer from 0 to 100
49+
@return nothing
50+
'''
51+
return self.__call_method__('_set_progress', progress)
52+
53+
def _set_message(self, message:str) -> None:
54+
'''
55+
@nodoc
56+
57+
@brief Sets a message in the main window progress bar
58+
@version 1
59+
60+
@param message the message to display
61+
@return nothing
62+
'''
63+
return self.__call_method__('_set_message', message)
64+
65+
66+
def _create_internal_progress_bar(passcode:str) -> None:
67+
'''
68+
gom.api.__internal__progress.InternalProgressBar
69+
70+
@nodoc
71+
72+
@brief Only for internal use!
73+
'''
74+
return gom.__api__.__call_function__(passcode)
75+

0 commit comments

Comments
 (0)