Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
b0002d18
Commit
b0002d18
authored
1 year ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fix unit tests
parent
e8cb53e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/instrumentation/memory/conditions.py
+10
-12
10 additions, 12 deletions
satella/instrumentation/memory/conditions.py
tests/test_instrumentation/test_memory.py
+1
-1
1 addition, 1 deletion
tests/test_instrumentation/test_memory.py
with
11 additions
and
13 deletions
satella/instrumentation/memory/conditions.py
+
10
−
12
View file @
b0002d18
import
functools
import
operator
import
typing
as
tp
from
abc
import
ABCMeta
,
abstractmethod
...
...
@@ -40,35 +41,32 @@ class ZerothSeverity(BaseCondition):
class
OperationJoin
(
BaseCondition
):
__slots__
=
(
'
conditions
'
,)
_OPERATOR
=
lambda
y
,
z
:
y
and
z
# pylint: disable=invalid-name
_STARTING_VALUE
=
False
# pylint: disable=invalid-name
def
__init__
(
self
,
*
conditions
:
BaseCondition
):
self
.
conditions
=
conditions
def
can_fire
(
self
,
local_memory_data
,
local_maximum_consume
:
tp
.
Optional
[
int
])
->
bool
:
return
functools
.
reduce
(
self
.
OPERATOR
,
(
return
functools
.
reduce
(
self
.
_
OPERATOR
,
(
condition
.
can_fire
(
local_memory_data
,
local_maximum_consume
)
for
condition
in
self
.
conditions
),
self
.
STARTING_VALUE
)
self
.
conditions
),
self
.
_
STARTING_VALUE
)
class
Any
(
OperationJoin
):
"""
This is true if one of the arguments is True
"""
__slots__
=
()
@staticmethod
def
OPERATOR
(
a
,
b
):
return
a
or
b
STARTING_VALUE
=
False
_OPERATOR
=
operator
.
or_
_STARTING_VALUE
=
False
class
All
(
OperationJoin
):
"""
This is true if all arguments are True
"""
__slots__
=
()
@staticmethod
def
OPERATOR
(
a
,
b
):
return
a
and
b
STARTING_VALUE
=
True
_OPERATOR
=
operator
.
and_
_STARTING_VALUE
=
True
class
Not
(
BaseCondition
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_instrumentation/test_memory.py
+
1
−
1
View file @
b0002d18
...
...
@@ -129,7 +129,7 @@ class TestMemory(unittest.TestCase):
self
.
assertEqual
(
a
[
'
mem_normal
'
],
1
)
a
[
'
level_2_engaged
'
]
=
True
time
.
sleep
(
3
)
self
.
assertEqual
(
MemoryPressureManager
().
objects_to_cleanup_on_entered
[
1
],
[]
)
self
.
assert
Less
Equal
(
len
(
MemoryPressureManager
().
objects_to_cleanup_on_entered
[
1
]
)
,
1
)
self
.
assertEqual
(
MemoryPressureManager
().
severity_level
,
2
)
self
.
assertEqual
(
a
[
'
cancelled
'
],
1
)
self
.
assertEqual
(
a
[
'
times_entered_1
'
],
2
)
...
...
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