Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
cld
ml
tvm
Commits
9f0e8ffe
Commit
9f0e8ffe
authored
6 years ago
by
Tianqi Chen
Browse files
Options
Downloads
Patches
Plain Diff
[PYTHON] Enable environment scoping (#33)
parent
7ab574b0
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
vta/python/vta/environment.py
+9
-0
9 additions, 0 deletions
vta/python/vta/environment.py
vta/tests/python/unittest/test_environment.py
+9
-0
9 additions, 0 deletions
vta/tests/python/unittest/test_environment.py
with
18 additions
and
0 deletions
vta/python/vta/environment.py
+
9
−
0
View file @
9f0e8ffe
...
...
@@ -143,6 +143,15 @@ class Environment(object):
self
.
mock_mode
=
False
self
.
_mock_env
=
None
self
.
_dev_ctx
=
None
self
.
_last_env
=
None
def
__enter__
(
self
):
self
.
_last_env
=
Environment
.
current
Environment
.
current
=
self
return
self
def
__exit__
(
self
,
ptype
,
value
,
trace
):
Environment
.
current
=
self
.
_last_env
def
pkg_config
(
self
):
"""
PkgConfig instance
"""
...
...
This diff is collapsed.
Click to expand it.
vta/tests/python/unittest/test_environment.py
+
9
−
0
View file @
9f0e8ffe
...
...
@@ -6,6 +6,15 @@ def test_env():
mock
=
env
.
mock
assert
mock
.
alu
==
"
skip_alu
"
def
test_env_scope
():
env
=
vta
.
get_env
()
cfg
=
env
.
pkg_config
().
cfg_dict
cfg
[
"
TARGET
"
]
=
"
xyz
"
with
vta
.
Environment
(
cfg
):
assert
vta
.
get_env
().
TARGET
==
"
xyz
"
assert
vta
.
get_env
().
TARGET
==
env
.
TARGET
if
__name__
==
"
__main__
"
:
test_env
()
test_env_scope
()
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