- Sphere Engine overview
- Compilers
- Overview
- API
- Widgets
- Resources
- Problems
- Overview
- API
- Widgets
- Handbook
- Resources
- Containers
- Overview
- Glossary
- API
- Workspaces
- Handbook
- Resources
- RESOURCES
- Programming languages
- Modules comparison
- Webhooks
- Infrastructure management
- API changelog
- FAQ
This is a technical reference for the Python's se_utils
package in the Sphere Engine Containers.
This package is guarantee to be compatible with a Python 3 delivered in the built-in Sphere Engine Containers project templates. It is available for straightforward import to your Python scripts.
Here you will find a detailed description covering:
- list of utilities and their functionality,
- discussion on typical use cases,
- usage examples.
Package overview
The following presents a simplified reference for the se_utils
package. For clarity, we separated all modules.
Module se_utils.evaluator
The evaluator
module contains tools used for carrying out the whole evaluation process taken in the test
stage of
the scenario. It uses a chain of sub-tools from different modules: se_utils.validator
, se_utils.converter
,
and se_utils.grader
.
Module structure:
se_utils.evaluator
class Evaluator
constructor(validator: Validator, converter: Converter, grader: Grader)
run()
class UnitTestsEvaluator(Evaluator)
class IOEvaluator(Evaluator)
Example:
from se_utils.evaluator import UnitTestsEvaluator
from se_utils.converter import XUnitConverter
my_ut_report_path='/home/user/workspace/my_report.xml'
UnitTestsEvaluator(
validator=XUnitValidator(ut_report_path=my_ut_report_path),
converter=XUnitConverter(ut_report_path=my_ut_report_path),
).run()
Resources:
Module se_utils.validator
The validator
module contains tools responsible for checking a validity of intermediate results usually obtained
during the run
stage of the scenario's execution. These tools are rather incorporated as sub-tools of the tools
from the evaluator
module. Nonetheless, they can also be used independently, if necessary.
Module structure:
se_utils.validator
class Validator
validate()
class IgnoreExtraWhitespacesValidator(Validator)
class XUnitValidator(Validator)
Example:
from se_utils.validator import IgnoreExtraWhitespacesValidator
from se_utils.result import ScenarioResult
path_user_output = '/home/user/workspace/out.txt'
path_model_output = '/home/user/workspace/.sphere-engine/out.txt'
validator = IgnoreExtraWhitespacesValidator(path_user_output, path_model_output)
validation_output = validator.validate()
ScenarioResult.set(ScenarioResult.Status(validation_output['status']))
Resources:
Module se_utils.converter
(Test Result Converter
)
The converter
module contains tools responsible for unifying intermediate results obtained during the run
stage of
the scenarios's execution (and potentially also outcome of validation process). Similarly to tools from the validator
module, they are usually used as sub-tools of the tools from the evaluator
module. They can also be used
independently, if necessary.
The main task of the converter
tools is produce a final tests report that can be later consumed by the tools from the
grader
module. The technical reference covering a specification of the final tests report is covered in detail in a
separate document.
Module structure:
se_utils.converter
class Converter
convert(validator_output)
class XUnitConverter(Converter)
class IOConverter(Converter)
Example:
from se_utils.converter import XUnitConverter
user_junit_report = '/home/user/workspace/maven_project/target/report.xml'
converter = XUnitConverter(ut_report_path=user_junit_report)
converter.convert()
Resources:
Module se_utils.grader
The grader
module contains tools responsible for establishing the final result based on the
final tests report. produced by the tools from the
converter
module. The final result is usually a compilation of the final status
(e.g., OK
that states for a
success), the score
, and the execution time
.
Similarly to the tools from the validator
module, and the tools from the converter
module, the tools from the
grader
module are usually also used as a sub-tools of the tools from the evaluator
module. As with the others,
they can also be used independently, if necessary.
Module structure:
se_utils.grader
class Grader
grade()
class AtLeastOneTestPassedGrader(Grader)
class PercentOfSolvedTestsGrader(Grader)
class WeightedScoreTestsGrader(Grader)
get_test_case_weight_selector(test_case: TestCase) -> TestWeightSelector
class TestWeightSelector
classname: str = "*"
name: str = "*"
status: str = "ok"
weight: float
Example:
import shutil
from se_utils.grader import AtLeastOneTestPassedGrader
from se_utils import environment
path_custom_final_tests_report = '/home/user/workspace/custom_report.json'
shutil.copyfile(path_custom_tests_report, environment.path.final_tests_report)
grader = AtLeastOneTestPassedGrader()
grader.grade()
Resources:
- Python specification,
- CLI,
- PercentOfSolvedTestsGrader,
- AtLeastOneTestPassedGrader,
- WeightedScoreTestsGrader,
- Final tests report.
Module se_utils.result
The result
module contains tools that allows you to manage the final result of the scenario's execution.
You can use it to:
- set final parameters:
status
,time
, andscore
, - get current final parameters:
status
,time
, andscore
.
Module structure:
se_utils.result
class ScenarioResult
class Status
OK: str
FAIL: str
BE: str
RE: str
TLE: str
PE: str
IE: str
status: Status
score: float
time: float
classmethod get() -> ScenarioResult
classmethod set (status: Status, score: float, time: float)
classmethod set_ok (score: float, time: float)
classmethod set_fail (score: float, time: float)
classmethod set_build_error()
Example:
from se_utils.result import ScenarioResult
# get final status to variable
result = ScenarioResult.get()
final_status = result.status
# set final status to FAIL
ScenarioResult.set(ScenarioResult.Status.FAIL)
Resources:
Module se_utils.stage
The stage
module contains tools that allows you for accessing an outcome of particular stages, mainly init
, build
,
run
, and test
.
For each supported stage, you can use it to get the following:
stdout
- output data produced during the stage,- or the path to the file containing
stdout
data,
- or the path to the file containing
stderr
- error data produced during the stage,- or the path to the file containing
stderr
data,
- or the path to the file containing
exit_code
- the exit code returned by the stage command,signal
- the code of a signal that stopped the stage command.
Module structure:
se_utils.stage
class Stage
stdout () -> str
stdout_path: str
stderr () -> str
stderr_path: str
exit_code: int
signal: int
init_stage: Stage
build_stage: Stage
run_stage: Stage
test_stage: Stage
Note that the stage
module doesn't allow for accessing the post
stage results. This is because during a scenario
execution, the post
stage is the very last, so these outcomes aren't there yet.
Example:
from se_utils.stage import run_stage
from se_utils.result import ScenarioResult
if 'Hello Sphere Engine Containers!' in run_stage.stdout():
ScenarioResult.set_ok()
else:
ScenarioResult.set_fail()
Resources:
Module se_utils.environment
The environment
module contains tools providing an easy access to various constants, parameters, paths, names, URLs,
and more.
Module structure:
se_utils.environment
path
workspace: str
runtime: str
runtime_data: str
final_tests_report: str
unit_tests_report: str
test_cases: str
network
port_http: int
port_mysql: int
port_mongodb: int
port_vnc: int
remote_url (port: int) -> str
current_stage: str
Example:
from se_utils import environment
project_website_url = environment.network.remote_url(8080)
final_tests_report = environment.path.final_tests_report
Resources:
Module se_utils.webhook
The webhook
module contains a tool for sending webhooks during the scenario execution.
Module structure:
se_utils.webhook
CustomWebhook()
Example:
from se_utils.webhook import CustomWebhook
CustomWebhook().send()
Resources:
Module se_utils.debug
The debug
module contains tools providing facilities and shorthands for debugging procedures. It is intended to be
used by the Content Manager for their internal purposes that should be separated from the end-user experience.
Module structure:
se_utils.debug
debug_log (msg: str)
Example:
from se_utils.debug import debug_log
debug_log('this is an internal note for Content Manager access only')
Resources:
Specification
In this section we present a detailed specification for all modules of the se_utils
package.
Module se_utils.evaluator
If you are looking for a CLI equivalent of this module, please go here.
class Evaluator
Representation of the evaluator - the tool used for carrying out the evaluation process.
constructor(validator, converter, grader)
Create an Evaluator
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
validator | Validator |
Instance of Validator or Validator class |
No | None |
converter | Converter |
Instance of Converter or Converter class |
No | None |
grader | Grader |
Instance of Grader or Grader class |
No | None |
Raises:
SEEvaluatorException
method run()
Perform the evaluation process. Typically, the chain of the following operations:
validator.validate() -> converter.convert() -> grader.grade()
.
Raises:
SEValidatorException
,SEConverterException
,SEGraderException
.
Example:
from se_utils.evaluator import Evaluator
from se_utils.validator import XUnitValidator
from se_utils.converter import XUnitConverter
from se_utils.grader import PercentOfSolvedTestsGrader
Evaluator(
validator=XUnitValidator,
converter=XUnitConverter,
grader=PercentOfSolvedTestsGrader,
).run()
class UnitTestsEvaluator(Evaluator)
Representation of the unit tests evaluator - the tool used for evaluation of the scenario execution based on the passed unit tests.
It derives from the Evaluator
class.
constructor(validator, converter, grader)
Create a UnitTestsEvaluator
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
validator | Validator |
Instance of Validator or Validator class |
No | XUnitValidator |
converter | Converter |
Instance of Converter or Converter class |
No | XUnitConverter |
grader | Grader |
Instance of Grader or Grader class |
No | PercentOfSolvedTestsGrader |
Raises:
SEEvaluatorException
.
Example:
from se_utils.evaluator import UnitTestsEvaluator
UnitTestsEvaluator().run()
class IOEvaluator(Evaluator)
Representation of the IO evaluator - the tool used for evaluation of the scenario execution based on the
comparison between the model test output data against the run
stage output data generated for the test input data.
It derives from the Evaluator
class.
constructor(validator, converter, grader)
Create an IOEvaluator
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
validator | Validator |
Instance of Validator or Validator class |
No | IgnoreExtraWhitespacesValidator |
converter | Converter |
Instance of Converter or Converter class |
No | IOConverter |
grader | Grader |
Instance of Grader or Grader class |
No | AtLeastOneTestPassedGrader |
Raises:
SEEvaluatorException
.
Example:
from se_utils.evaluator import UnitTestsEvaluator
IOEvaluator().run()
Resources:
Module se_utils.validator
If you are looking for a CLI equivalent of this module, please go here.
abstract class Validator
Representation of the validator - the tool used for checking a validity of intermediate results usually obtained during
the run
stage.
abstract method validate()
Perform validation procedure.
Raises:
SEValidatorException
.
class XUnitValidator(Validator)
Representation of the unit tests validator for unit test reports compatible with the xUnit
schema.
It derives from the Validator
class.
constructor(ut_report_path)
Create a XUnitValidator
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
ut_report_path | string |
Path to unit tests report file | No | (default path to the unit tests report file) |
Raises:
SEValidatorException
.
Example:
from se_utils.validator import XUnitValidator
from se_utils.result import ScenarioResult
my_ut_report_path='/home/user/workspace/ut_report.xml'
validator = XUnitValidator(ut_report_path=my_ut_report_path)
validation_output = validator.validate()
ScenarioResult.set(ScenarioResult.Status(validation_output['status']))
class IgnoreExtraWhitespacesValidator(Validator)
Representation of the IO validator designed for comparing the model test output data against the run stage output data generated for the test input data.
It derives from the Validator
class.
constructor(program_output, test_case_output)
Create a IgnoreExtraWhitespacesValidator
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
program_output | string |
Path to the output of the program | No | (default path to the run stage stdout) |
test_case_output | string |
Path to the output of the program | No | (default path to the model test case output file) |
Raises:
SEValidatorException
.
Example:
from se_utils.validator import IgnoreExtraWhitespacesValidator
from se_utils.result import ScenarioResult
path_user_output = '/home/user/workspace/out.txt'
path_model_output = '/home/user/workspace/.sphere-engine/out.txt'
validator = IgnoreExtraWhitespacesValidator(path_user_output, path_model_output)
validation_output = validator.validate()
ScenarioResult.set(ScenarioResult.Status(validation_output['status']))
Resources:
Module se_utils.converter
If you are looking for a CLI equivalent of this module, please go here.
abstract class Converter
Representation of the converter - the tool used for producing a final tests report.
abstract method convert(validator_output)
Perform conversion procedure.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
validator_output | any |
Any kind of information about data from a validation process | No | None |
Raises:
SEConverterException
.
method create_final_tests_report(test_cases)
Create a final tests report.
Parameters:
Name | Type | Description | Required |
---|---|---|---|
test_cases | list[TestCase] |
List of test results | Yes |
Raises:
SEConverterException
.
class XUnitConverter(Converter)
Representation of the unit test converter designed for creating final tests reports based on unit test reports
compatible with the xUnit
schema (e.g., jUnit
).
It derives from the Converter
class.
constructor(ut_report_path)
Create a XUnitConverter
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
ut_report_path | string |
Path to unit tests report file | No | (default path to the unit tests report file) |
Raises:
SEValidatorException
.
Example:
from se_utils.converter import XUnitConverter
user_junit_report = '/home/user/workspace/maven_project/target/report.xml'
converter = XUnitConverter(ut_report_path=user_junit_report)
converter.convert()
class IOConverter(Converter)
Representation of the unit test converter designed for creating final tests reports based on IO tests.
It derives from the Converter
class.
constructor(validator_output)
Create a IOConverter
object.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
validator_output | any |
Any kind of information about data from a validation process | No | None |
Raises:
SEValidatorException
.
Example:
from se_utils.converter import IOConverter
converter = IOConverter()
converter.convert()
Resources:
Module se_utils.grader
If you are looking for a CLI equivalent of this module, please go here.
abstract class Grader
Representation of the grader - the tool used for establishing the final result. The final result is usually a
compilation of the final status
(e.g., OK
that states for a success), the score
, and the execution time
.
abstract method grade()
Perform grading procedure.
Raises:
SEGraderException
.
method get_final_tests_report()
Get tests from the final tests report.
Returns: list[TestCase]
Raises:
SEGraderException
.
class PercentOfSolvedTestsGrader(Grader)
Representation of the grader that accepts execution as successful (i.e., the status
is set to OK
) when at least
one test from the final tests report is successful. The final score
is set as a percentage of passed tests.
It derives from the Grader
class.
Example:
import shutil
from se_utils.grader import PercentOfSolvedTestsGrader
from se_utils import environment
path_custom_final_tests_report = '/home/user/workspace/custom_report.json'
shutil.copyfile(path_custom_tests_report, environment.path.final_tests_report)
grader = PercentOfSolvedTestsGrader()
grader.grade()
class AtLeastOneTestPassedGrader(Grader)
Representation of the grader that accepts execution as successful (i.e., the status
is set to OK
) when at least
one test from the final tests report is successful. It does not set any score
.
It derives from the Grader
class.
Example:
from se_utils.grader import AtLeastOneTestPassedGrader
grader = AtLeastOneTestPassedGrader()
grader.grade()
class WeightedScoreTestsGrader(Grader)
Representation of the grader that accepts execution as successful (i.e., the status
is set to OK
) when
the final score is positive (score>=0
). The final score
is set as a sum of weights for all passing tests.
It derives from the Grader
class.
Raises:
SEGraderException
.
constructor(weights_selectors=None, default_test_weight=1)
Create an WeightedScoreTestsGrader
class.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
weights_selectors | Optional[List[TestWeightSelector]] |
Weight selector that specify weights for collections or individual test cases | No | [] |
default_test_weight | float |
Default weight for a test that succeeded but matched no selector | No | 1 |
get_test_case_weight_selector(test_case: TestCase) -> TestWeightSelector
For a specific TestCase
retrieve test case selector used to obtain weight for that test.
This method is used under the hood by grade()
for WeightedScoreTestsGrader
.
You can use it to debug you test case selectors.
Name | Type | Description | Required | Default |
---|---|---|---|---|
test_case | TestCase |
Test case to retrieve selector with weight for | Yes |
Example:
from se_utils.grader import WeightedScoreTestsGrader
grader = WeightedScoreTestsGrader()
grader.grade()
class TestWeightSelector(Grader)
Dataclass representing test weight selector for WeightedScoreTestsGrader
.
A selector is an object that specifies the following properties:
dataclass field classname
(optional str)
dataclass field name
(optional str)
dataclass field status
(optional str)
dataclass field weight
(required float)
classname
- matches the class name of the test."*"
matches any class name. By default"*"
is used if the property is not explicitly specified,name
- matches the name of the test case."*"
matches any name. By default"*"
is used if the property is not explicitly specified,status
- matches the status of the test."*"
to match any test case status. This property is handy when you want to assign negative scores to the tests that fail. The status of the test can befailure
,ok
orerror
. ("ok"
is the default value),weights
- weight for the test case that matches that selector. This is a required field without a default value.
For more selector use cases please see full project example or WeightedScoreTestsGrader documentation.
constructor(weight, classname="*", name="*", status="ok")
Create an TestWeightSelector
dataclass.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
weight | float |
Weight assigned to the test case selector | Yes | |
classname | str |
Test class name that this selector applies to | No | "*" |
name | str |
Test case name that this selector applies to | No | "*" |
status | str |
Test case evaluation status that this selector applies to | No | "ok" |
Example:
from se_utils.grader import TestWeightSelector, WeightedScoreTestsGrader
selector_default = TestWeightSelector(weight="1")
selector_failure = TestWeightSelector(weight="1", classname="TestCaseClass", status="failure")
selector_all = TestWeightSelector(weight="10", classname="*", name="*", status="*")
all_selectors = [selector_default, selector_failure, selector_all]
print(all_selectors)
grader = WeightedScoreTestsGrader(all_selectors)
grader.grade()
Resources:
- Python overview,
- CLI,
- PercentOfSolvedTestsGrader,
- AtLeastOneTestPassedGrader,
- WeightedScoreTestsGrader,
- Final tests report.
Module se_utils.result
If you are looking for a CLI equivalent of this module, please go here.
class ScenarioResult
Representation of the scenario result - the tool used for manual management of the final result of the scenario's execution.
class Status(Enum)
Enumeration of possible values for final status.
class field OK
class field FAIL
class field BE
(build error)
class field RE
(run-time error)
class field TLE
(time limit exceeded)
class field PE
(project error)
class field IE
(internal error of Sphere Engine)
field status
Final status of the scenario's execution. One of the following:
Status.OK
,Status.FAIL
,Status.BE
,Status.RE
,Status.TLE
,Status.PE
,Status.IE
.
Type: Status
field score
Final score of the scenario's execution.
Type: float
field time
Final execution time of the scenario's execution.
Type: float
class method get()
Get current state of final result (i.e., final status
, score
, and time
).
Note: this method is allowed to be used only in the test
stage.
Returns: ScenarioResult
Raises:
SEScenarioResultException
.
class method set(status, score, time)
Set final result (i.e., final status
, score
, and time
).
Note: if some parameters are not provided (or None
is provided), then the value does not change.
Note: using this method is possible only in the following stages:
- always during the
test
stage, - during the
build
stage for setting build error status (i.e.,status=Status.BE
).
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
status | Status |
Final status |
No | None |
score | float |
Final score |
No | None |
time | float |
Final time |
No | None |
Returns: ScenarioResult
Raises:
SEScenarioResultException
.
class method set_ok(score, time)
Set positive (i.e., status=OK
) final result with optional custom score
and execution time
.
Note: if some parameters are not provided (or None
is provided), then the value does not change.
Note: using this method is possible only in the following stages:
- always during the
test
stage, - during the
build
stage for setting build error status (i.e.,status=Status.BE
).
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
score | float |
Final score |
No | None |
time | float |
Final time |
No | None |
Returns: ScenarioResult
Raises:
SEScenarioResultException
.
class method set_fail(score, time)
Set negative (i.e., status=FAIL
) final result with optional custom score
and execution time
.
Note: if some parameters are not provided (or None
is provided), then the value does not change.
Note: using this method is possible only in the following stages:
- always during the
test
stage, - during the
build
stage for setting build error status (i.e.,status=Status.BE
).
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
score | float |
Final score |
No | None |
time | float |
Final time |
No | None |
Returns: ScenarioResult
Raises:
SEScenarioResultException
.
class method set_build_error()
Set final result as failure during build
stage (i.e., status=BE
).
Note: using this method is possible only in the following stages: test
and build
.
Returns: ScenarioResult
Raises:
SEScenarioResultException
.
method save()
Save current ScenarioResult
object state (i.e., fields status
, score
, and time
) as a final result.
Raises:
SEScenarioResultException
.
Example:
from se_utils.result import ScenarioResult
# get final status to variable
result = ScenarioResult.get()
final_status = result.status
# set final status to FAIL
ScenarioResult.set(ScenarioResult.Status.FAIL)
# set final status to build error
ScenarioResult.set_build_error()
Resources:
Module se_utils.stage
If you are looking for a CLI equivalent of this module, please go here.
class Stage
Representation of the stage result.
Available for stages: init
, build
, run
, and test
. Unavailable for stage post
.
Note: it's not necessary to initiate this object for any stage. Pre-initiate objects are available for
importing directly from the module: init_stage
, build_stage
, run_stage
, test_stage
. You will find
more information about these object below.
constructor()
Create a Stage
object for a given stage.
Parameters:
Name | Type | Description | Required |
---|---|---|---|
stage_name | string |
The name of the stage | Yes |
Raises:
SEStageException
.
field stage_name
The name of the stage.
Type: string
field stdout_path
Path to the file with stdout
data of the stage.
Type: string
field stderr_path
Path to the file with stderr
data of the stage.
Type: string
field exit_code
The exit code returned by the stage command.
Note: If stage has not been executed, then the value is empty (None
).
Type: integer
field signal
The code of a signal that stopped the stage command.
Note: If the stage has not been stopped by a signal, then the value is empty (None
).
Type: integer
method stdout()
Get content of the stdout
data of the stage.
Warning: this method will load entire, potentially huge, content to memory.
Raises:
SEScenarioResultException
.
method stderr()
Get content of the stderr
data of the stage.
Warning: this method will load entire, potentially huge, content to memory.
Raises:
SEScenarioResultException
.
class method is_available(stage_name)
Check if outcome of a given stage is available.
Parameters:
Name | Type | Description | Required |
---|---|---|---|
stage_name | string |
The name of the stage | Yes |
Returns: boolean
Raises:
SEStageException
.
Example:
from se_utils.stage import build_stage
from se_utils.stage import run_stage
contents_stderr_build_stage = build_stage.stderr()
path_stdout_run_stage = run_stage.stdout_path
object init_stage
Preloaded State
object for the init
stage.
Note: available for the following stages: build
, run
, test
, post
.
Example:
from se_utils.stage import init_stage
init_stage_error = init_stage.stderr()
init_stage_output_path = init_stage.stdout_path
object build_stage
Preloaded State
object for the build
stage.
Note: available for the following stages: run
, test
, post
.
Example:
from se_utils.stage import build_stage
build_stage_error = build_stage.stderr()
build_stage_output_path = build_stage.stdout_path
object run_stage
Preloaded State
object for the run
stage.
Note: available for the following stages: test
, post
.
Example:
from se_utils.stage import run_stage
run_stage_error = run_stage.stderr()
run_stage_output_path = run_stage.stdout_path
object test_stage
Preloaded State
object for the test
stage.
Note: available for the following stages: post
.
Example:
from se_utils.stage import test_stage
test_stage_error = test_stage.stderr()
test_stage_output_path = test_stage.stdout_path
Resources:
Module se_utils.environment
If you are looking for a CLI equivalent of this module, please go here.
package path
Group of path parameters. Contains path to files, directory, and other resources.
field workspace
Path to the user workspace directory.
Type: string
Default: /home/user/workspace
field runtime
Path to the Sphere Engine run-time directory. This directory contains critical files during the execution of the scenario.
Type: string
Default: /home/user/runtime
field runtime_data
Path to the Sphere Engine run-time data directory. This directory is dedicated for Content Managers as a general
purpose storage during the execution of the scenario.
Type: string
Default: /home/user/runtime_data
field final_tests_report
Path to the file with the final tests report.
Type: string
Default: /home/user/runtime/report.json
field unit_tests_report
Path to the default place for unit tests report (e.g., jUnit
XML report).
Type: string
Default: /home/user/runtime/report.xml
field test_cases
Path to the default directory for IO tests.
Type: string
Default: /home/user/workspace/.sphere-engine/test-cases
Example:
from se_utils import environment
workspace_directory = environment.path.workspace
final_tests_report = environment.path.final_tests_report
package network
Group of network parameters. Contains values for network-related parameters like URLs, ports, and others.
field port_http
Default port for the build-in HTTP
server.
Type: integer
field port_mysql
Default port for the build-in MySQL
database server.
Type: integer
field port_mongodb
Default port for the build-in MongoDB
database server.
Type: integer
field port_vnc
Default port for the build-in VNC
remote desktop server.
Type: integer
function remote_url(port)
Get a URL address with external port number for a given internal port number.
Parameters:
Name | Type | Description | Required | Default |
---|---|---|---|---|
port | integer |
Internal port number | No | environment.network.port_http |
Returns: string
Raises:
SEEnvironmentException
.
Example:
from se_utils import environment
mysql_port = environment.network.port_mysql
project_website_url = environment.network.remote_url(8080)
field current_stage
Get the name of current stage.
Type: string
Values: init
, build
, run
, test
, or post
Example:
from se_utils import environment
current_stage_name = environment.current_stage
Resources:
Module se_utils.webhook
If you are looking for a CLI equivalent of this module, please go here.
class CustomWebhook
CustomWebhook is a tool for sending custom webhooks.
constructor()
Create a CustomWebhook
object.
Raises:
SEWebhookException
.
method send()
Send a webhook.
Raises:
SEWebhookException
.
Example:
from se_utils.webhook import CustomWebhook
CustomWebhook().send()
Resources:
Module se_utils.debug
If you are looking for a CLI equivalent of this module, please go here.
function debug_log(msg)
Print a message (or messages) to the dedicated stream for debugging logs.
Parameters:
Name | Type | Description | Required |
---|---|---|---|
msg | string or list or tuple or set or object |
Entity that is expected to be logged | Yes |
Notes:
- if the
msg
value isstring
, then the value is directly logged, - if the
msg
value isobject
, then the result ofstr()
of it conversion is logged, - for
list
,tuple
andset
collection types, the new-line separated sequence of logs is logged, each of them is the result ofstr()
conversion of the collection item.
Raises:
SEEnvironmentException
.
Example:
from se_utils.debug import debug_log
debug_log('this is an internal note for Content Manager access only')
Resources:
Exceptions se_utils.exceptions
exception class SEUtilsException
General type of se_utils
package exceptions.
All other exceptions derive from this exception class.
Raised by:
Currently this exception is not raised by any module of se_utils
package.
exception class SEEvaluatorException
Raised for any invalid or incorrect operation related to evaluators.
It derives from the SEUtilsException
exception class.
Raised by:
- constructors of evaluators,
Evaluator.run()
method.
exception class SEValidatorException
Raised for any invalid or incorrect operation related to validators.
It derives from the SEUtilsException
exception class.
Raised by:
IgnoreExtraWhitespacesValidator.validate()
method,XUnitValidator.validate()
method,- constructors of evaluators.
exception class SEConverterException
Raised for any invalid or incorrect operation related to converters.
It derives from the SEUtilsException
exception class.
Raised by:
Converter.create_final_tests_report()
method,Converter.convert()
method,- constructors of evaluators.
exception class SEGraderException
Raised for any invalid or incorrect operation related to graders.
It derives from the SEUtilsException
exception class.
Raised by:
Grader.get_final_tests_report()
method,- constructors of evaluators.
exception class SEStageException
Raised for any invalid or incorrect operation related to the stage
module.
It derives from the SEUtilsException
exception class.
Raised by:
Stage
class constructor,Stage.stdout()
method,Stage.stderr()
method,Stage.is_available()
class method.
exception class SEScenarioResultException
Raised for any invalid or incorrect operation related to the scenario result
module.
It derives from the SEUtilsException
exception class.
Raised by:
ScenarioResult
class constructor,ScenarioResult.save()
method,ScenarioResult.set()
class method,ScenarioResult.set_build_error()
class method,ScenarioResult.set_fail()
class method,ScenarioResult.set_ok()
class method,ScenarioResult.get()
class method.
exception class SEEnvironmentException
Raised for any invalid or incorrect operation related to the environment
module.
It derives from the SEUtilsException
exception class.
Raised by:
remote_url()
function.
exception class SEDebugLogException
Raised for any invalid or incorrect operation related to the debug
module.
It derives from the SEUtilsException
exception class.
Raised by:
debug_log
function.