Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wax
Commits
f22d4b52
Commit
f22d4b52
authored
4 months ago
by
Jakub Ziebinski
Browse files
Options
Downloads
Patches
Plain Diff
Add an result_tools module
parent
355fab70
No related branches found
No related tags found
1 merge request
!230
Implementation of the python wax interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/wax/_private/result_tools.py
+47
-0
47 additions, 0 deletions
python/wax/_private/result_tools.py
with
47 additions
and
0 deletions
python/wax/_private/result_tools.py
0 → 100644
+
47
−
0
View file @
f22d4b52
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
wax._private.exceptions
import
WaxValidationFailedError
from
wax.wax_result
import
python_error_code
,
python_result
if
TYPE_CHECKING
:
from
wax._private.models.basic
import
AccountName
def
to_python_string
(
value
:
bytes
|
str
)
->
str
:
if
isinstance
(
value
,
str
):
return
value
return
value
.
decode
()
def
to_cpp_string
(
value
:
bytes
|
str
)
->
bytes
:
if
isinstance
(
value
,
str
):
return
value
.
encode
()
return
value
def
validate_wax_result
(
result
:
python_result
)
->
None
:
if
result
.
status
==
python_error_code
.
fail
:
raise
WaxValidationFailedError
(
to_python_string
(
result
.
exception_message
))
def
expose_result_as_python_string
(
result
:
python_result
)
->
str
:
return
to_python_string
(
result
.
result
)
def
expose_result_as_cpp_string
(
result
:
python_result
)
->
bytes
:
return
result
.
result
def
decode_impacted_account_names
(
account_names
:
list
[
bytes
])
->
list
[
AccountName
]:
"""
Decode account names from bytes to str.
Args:
account_names: List of account names in bytes.
Returns:
List of account names.
"""
return
[
to_python_string
(
account_name
)
for
account_name
in
account_names
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment