Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
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
pycodegen
pystencils
Commits
25c2f11f
Commit
25c2f11f
authored
6 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
use a lockfile to restrict concurrent access to the CPU JIT config file
parent
8081e9b2
No related branches found
No related tags found
1 merge request
!446
Use a lockfile to restrict concurrent access to the CPU JIT config file
Pipeline
#72949
passed with warnings
6 months ago
Stage: pretest
Stage: test
Stage: docs
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/pystencils/cpu/cpujit.py
+20
-13
20 additions, 13 deletions
src/pystencils/cpu/cpujit.py
with
21 additions
and
14 deletions
pyproject.toml
+
1
−
1
View file @
25c2f11f
...
...
@@ -12,7 +12,7 @@ authors = [
]
license
=
{
file
=
"COPYING.txt"
}
requires-python
=
">
=
3.10
"
dependencies
=
["sympy>=1.9,<
=
1.12
.
1
", "
numpy>
=
1.8
.
0
", "
appdirs
", "
joblib
", "
pyyaml
"]
dependencies
=
["sympy>=1.9,<
=
1.12
.
1
", "
numpy>
=
1.8
.
0
", "
appdirs
", "
joblib
", "
pyyaml
"
, "
fasteners
"
]
classifiers
=
[
"Development Status :: 4 - Beta"
,
"Framework :: Jupyter"
,
...
...
This diff is collapsed.
Click to expand it.
src/pystencils/cpu/cpujit.py
+
20
−
13
View file @
25c2f11f
...
...
@@ -57,6 +57,7 @@ import tempfile
import
textwrap
import
time
import
warnings
import
pathlib
import
numpy
as
np
...
...
@@ -122,15 +123,15 @@ def get_configuration_file_path():
# 1) Read path from environment variable if found
if
'
PYSTENCILS_CONFIG
'
in
os
.
environ
:
return
os
.
environ
[
'
PYSTENCILS_CONFIG
'
]
,
True
return
os
.
environ
[
'
PYSTENCILS_CONFIG
'
]
# 2) Look in current directory for pystencils.json
elif
os
.
path
.
exists
(
"
pystencils.json
"
):
return
"
pystencils.json
"
,
True
return
"
pystencils.json
"
# 3) Try ~/.pystencils.json
elif
os
.
path
.
exists
(
config_path_in_home
):
return
config_path_in_home
,
True
return
config_path_in_home
else
:
return
config_path_in_home
,
False
return
config_path_in_home
def
create_folder
(
path
,
is_file
):
...
...
@@ -190,16 +191,22 @@ def read_config():
default_config
=
OrderedDict
([(
'
compiler
'
,
default_compiler_config
),
(
'
cache
'
,
default_cache_config
)])
config_path
,
config_exists
=
get_configuration_file_path
()
from
fasteners
import
InterProcessLock
config_path
=
pathlib
.
Path
(
get_configuration_file_path
())
config_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
config
=
default_config
.
copy
()
if
config_exists
:
with
open
(
config_path
,
'
r
'
)
as
json_config_file
:
loaded_config
=
json
.
load
(
json_config_file
)
config
=
recursive_dict_update
(
config
,
loaded_config
)
else
:
create_folder
(
config_path
,
True
)
with
open
(
config_path
,
'
w
'
)
as
f
:
json
.
dump
(
config
,
f
,
indent
=
4
)
lockfile
=
config_path
.
with_suffix
(
config_path
.
suffix
+
"
.lock
"
)
with
InterProcessLock
(
lockfile
):
if
config_path
.
exists
():
with
open
(
config_path
,
'
r
'
)
as
json_config_file
:
loaded_config
=
json
.
load
(
json_config_file
)
config
=
recursive_dict_update
(
config
,
loaded_config
)
else
:
with
open
(
config_path
,
'
w
'
)
as
f
:
json
.
dump
(
config
,
f
,
indent
=
4
)
if
config
[
'
cache
'
][
'
object_cache
'
]
is
not
False
:
config
[
'
cache
'
][
'
object_cache
'
]
=
os
.
path
.
expanduser
(
config
[
'
cache
'
][
'
object_cache
'
]).
format
(
pid
=
os
.
getpid
())
...
...
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