Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
dorie
dorie
Commits
79a3cb0d
Commit
79a3cb0d
authored
Sep 06, 2018
by
Lukas Riedel
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Move 'dorie' wrapper into Python package."
This reverts commit
57729908
.
parent
69eb43f5
Changes
13
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
159 additions
and
181 deletions
+159
-181
.gitignore
.gitignore
+0
-2
CMakeLists.txt
CMakeLists.txt
+1
-0
bin/CMakeLists.txt
bin/CMakeLists.txt
+8
-0
bin/dorie.in
bin/dorie.in
+144
-0
python/CMakeLists.txt
python/CMakeLists.txt
+0
-1
python/dorie/dorie/cli/CMakeLists.txt
python/dorie/dorie/cli/CMakeLists.txt
+0
-1
python/dorie/dorie/cli/__init__.py
python/dorie/dorie/cli/__init__.py
+0
-0
python/dorie/dorie/cli/cmds.py
python/dorie/dorie/cli/cmds.py
+0
-77
python/dorie/dorie/cli/parser.py
python/dorie/dorie/cli/parser.py
+0
-77
python/dorie/setup.py
python/dorie/setup.py
+0
-1
python/dorie/wrapper/CMakeLists.txt
python/dorie/wrapper/CMakeLists.txt
+0
-1
python/dorie/wrapper/dorie.in
python/dorie/wrapper/dorie.in
+0
-19
python/dorie/wrapper/test_dorie.py.in
python/dorie/wrapper/test_dorie.py.in
+6
-2
No files found.
.gitignore
View file @
79a3cb0d
...
...
@@ -2,10 +2,8 @@
build-cmake/
# Exclude generated files
python/dorie/wrapper/dorie
python/dorie/wrapper/pf_from_file.py
python/dorie/wrapper/test_dorie.py
python/dorie/cli/cmds.py
# Ignore temporary and auto-generated files #
*~
...
...
CMakeLists.txt
View file @
79a3cb0d
...
...
@@ -41,6 +41,7 @@ dune_enable_all_packages()
dune_require_cxx_standard
(
MODULE
"dorie"
VERSION 14
)
# add subdirectories
add_subdirectory
(
"bin"
)
add_subdirectory
(
"m4"
)
add_subdirectory
(
"cmake/modules"
)
add_subdirectory
(
"python"
)
...
...
bin/CMakeLists.txt
0 → 100644
View file @
79a3cb0d
configure_file
(
dorie.in
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/dorie @ONLY
)
# copy the temporary file into the final destination, setting the permissions
file
(
COPY
${
CMAKE_BINARY_DIR
}${
CMAKE_FILES_DIRECTORY
}
/dorie
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install
(
PROGRAMS
${
CMAKE_CURRENT_BINARY_DIR
}
/dorie DESTINATION
${
CMAKE_INSTALL_BINDIR
}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
pytho
n/dorie
/dorie/cli/cmds.py
.in
→
bi
n/dorie.in
View file @
79a3cb0d
#!/usr/bin/env python3
import
os
import
sys
import
shutil
import
argparse
import
warnings
import
subprocess
import
multiprocessing
try
:
# Python 2.x compatibility
input
=
raw_input
...
...
@@ -14,10 +19,12 @@ MPIEXEC = "@MPIEXEC@"
MPIEXEC_NUMPROC_FLAG
=
"@MPIEXEC_NUMPROC_FLAG@"
MPIEXEC_PREFLAG
=
"@MPIEXEC_PREFLAG@"
MPIEXEC_POSTFLAGS
=
"@MPIEXEC_POSTFLAGS@"
#
# set some paths
DORIE_EXECUTABLE
=
os
.
path
.
join
(
DORIEDIR
,
"dune/dorie/dorie"
)
PARAMETERDIR
=
os
.
path
.
join
(
DORIEDIR
,
"doc/default_files"
)
DORIE_PYTHON
=
os
.
path
.
join
(
DORIEDIR
,
"run-in-dune-env"
)
def
MPIRUN
(
nproc
,
exe
,
*
args
,
**
kwargs
):
mpi_flags
=
kwargs
.
get
(
"mpi_flags"
)
or
[]
return
[
k
for
k
in
[
MPIEXEC
,
MPIEXEC_NUMPROC_FLAG
,
str
(
nproc
)]
\
...
...
@@ -52,13 +59,13 @@ def pfg(args):
raise
IOError
(
"Configuration file {} not found"
.
format
(
args
[
"config"
]))
try
:
if
args
[
"parallel"
]
==
1
:
subprocess.check_call(["pf_from_file.py", args["config"]])
subprocess
.
check_call
([
DORIE_PYTHON
,
"pf_from_file.py"
,
args
[
"config"
]])
else
:
if
args
[
"mpi_flags"
]:
mpi_flags
=
[
"--mpi-flags="
+
f
for
f
in
args
[
"mpi_flags"
]]
else
:
mpi_flags
=
[]
subprocess.check_call(["pf_from_file.py", args["config"],
subprocess
.
check_call
([
DORIE_PYTHON
,
"pf_from_file.py"
,
args
[
"config"
],
"--parallel"
,
str
(
args
[
"parallel"
])]
+
mpi_flags
)
except
subprocess
.
CalledProcessError
:
print
(
"Error while running DORiE"
)
...
...
@@ -69,9 +76,69 @@ def plot(args):
raise
IOError
(
"File {} not found"
.
format
(
args
[
"vtk"
]))
try
:
if
args
[
"var"
]:
subprocess.check_call(["plot_vtk.py", "-f", args["vtk"], "--var", args["var"]])
subprocess
.
check_call
([
DORIE_PYTHON
,
"plot_vtk.py"
,
"-f"
,
args
[
"vtk"
],
"--var"
,
args
[
"var"
]])
else
:
subprocess.check_call(["plot_vtk.py", "-f", args["vtk"]])
subprocess
.
check_call
([
DORIE_PYTHON
,
"plot_vtk.py"
,
"-f"
,
args
[
"vtk"
]])
except
subprocess
.
CalledProcessError
:
print
(
"Error while running DORiE"
)
sys.exit(1)
\ No newline at end of file
sys
.
exit
(
1
)
if
__name__
==
"__main__"
:
# parse command line and call command handler
try
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
warn
:
parser
=
argparse
.
ArgumentParser
(
description
=
"DORiE command line interface"
,
epilog
=
"For more information check our online documentation: "
"http://dorie-docs.bitballoon.com (password: 'richards')."
)
subparsers
=
parser
.
add_subparsers
(
title
=
"Commands"
,
dest
=
"command"
)
subparsers
.
required
=
True
parser_create
=
subparsers
.
add_parser
(
'create'
,
description
=
"Copy example configuration to current folder."
,
help
=
"Copy example configuration to current folder."
)
parser_create
.
add_argument
(
'-f'
,
'--force'
,
help
=
"Override existing files."
,
action
=
"store_true"
)
parser_create
.
set_defaults
(
func
=
create
)
parser_pfg
=
subparsers
.
add_parser
(
'pfg'
,
help
=
"Start parameter field generator."
,
description
=
"Start parameter field generator."
,
usage
=
"%(prog)s <config> [-h] [-p [N]] [-m=MPI_FLAGS]"
)
parser_pfg
.
add_argument
(
'config'
,
help
=
"Configuration file for the parameter field generator. "
"Can be created with 'dorie create'."
)
parser_pfg
.
add_argument
(
'-p'
,
'--parallel'
,
metavar
=
'N'
,
nargs
=
'?'
,
default
=
1
,
const
=
multiprocessing
.
cpu_count
(),
type
=
int
,
required
=
False
,
help
=
"Run in parallel on N processes. "
"If N is not specified, run on all available CPU threads."
)
parser_pfg
.
add_argument
(
'-m'
,
'--mpi-flags'
,
action
=
"append"
,
required
=
False
,
help
=
"Additional flags that are passed to mpirun when run in parallel. "
"May be specified multiple times."
)
parser_pfg
.
set_defaults
(
func
=
pfg
)
parser_run
=
subparsers
.
add_parser
(
'run'
,
help
=
"Run DORiE."
,
description
=
"Run DORiE."
,
usage
=
"%(prog)s <config> [-h] [-p [N]] [-m=MPI_FLAGS]"
)
parser_run
.
add_argument
(
'config'
,
help
=
"DORiE configuration file. Can be created with 'dorie create'."
)
parser_run
.
add_argument
(
'-p'
,
'--parallel'
,
metavar
=
'N'
,
nargs
=
'?'
,
default
=
1
,
const
=
multiprocessing
.
cpu_count
(),
type
=
int
,
required
=
False
,
help
=
"Run in parallel on N processes. "
"If N is not specified, run on all available CPU threads."
)
parser_run
.
add_argument
(
'-m'
,
'--mpi-flags'
,
action
=
"append"
,
required
=
False
,
help
=
"Additional flags that are passed to mpirun when run in parallel. "
"May be specified multiple times."
)
parser_run
.
set_defaults
(
func
=
run
)
parser_plot
=
subparsers
.
add_parser
(
'plot'
,
help
=
"Plot a preview of a VTK file created by DORiE."
,
description
=
"Plot a preview of a VTK file created by DORiE."
,
usage
=
"%(prog)s <vtk> [-h] [--v [VAR [VAR ...]]]"
)
parser_plot
.
add_argument
(
'vtk'
,
help
=
"Input VTK file."
)
parser_plot
.
add_argument
(
'-v'
,
'--var'
,
nargs
=
'*'
,
required
=
False
,
help
=
"Plot only given variables. If not specified, all variables are plotted."
)
parser_plot
.
set_defaults
(
func
=
plot
)
try
:
args
=
parser
.
parse_args
()
except
SystemExit
:
sys
.
exit
(
1
)
args
.
func
(
vars
(
args
))
except
Exception
as
e
:
print
(
"dorie failed with ({0}) warning(s) and ({1}) error(s)"
.
format
(
len
(
warn
),
1
))
raise
python/CMakeLists.txt
View file @
79a3cb0d
...
...
@@ -3,7 +3,6 @@ set(DUNE_PYTHON_INSTALL_EDITABLE TRUE)
# install Python package
add_subdirectory
(
dorie/wrapper
)
add_subdirectory
(
dorie/dorie/cli
)
dune_python_install_package
(
PATH dorie
)
# set cache variable
...
...
python/dorie/dorie/cli/CMakeLists.txt
deleted
100644 → 0
View file @
69eb43f5
configure_file
(
cmds.py.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmds.py
)
\ No newline at end of file
python/dorie/dorie/cli/__init__.py
deleted
100644 → 0
View file @
69eb43f5
python/dorie/dorie/cli/cmds.py
deleted
100644 → 0
View file @
69eb43f5
import
os
import
sys
import
shutil
import
subprocess
try
:
# Python 2.x compatibility
input
=
raw_input
except
NameError
:
pass
# paths set by cmake
DORIEDIR
=
"/Users/lriedel/dune/dorie/build-cmake"
MPIEXEC
=
"/usr/local/bin/mpiexec"
MPIEXEC_NUMPROC_FLAG
=
"-n"
MPIEXEC_PREFLAG
=
""
MPIEXEC_POSTFLAGS
=
""
# set some paths
DORIE_EXECUTABLE
=
os
.
path
.
join
(
DORIEDIR
,
"dune/dorie/dorie"
)
PARAMETERDIR
=
os
.
path
.
join
(
DORIEDIR
,
"doc/default_files"
)
def
MPIRUN
(
nproc
,
exe
,
*
args
,
**
kwargs
):
mpi_flags
=
kwargs
.
get
(
"mpi_flags"
)
or
[]
return
[
k
for
k
in
[
MPIEXEC
,
MPIEXEC_NUMPROC_FLAG
,
str
(
nproc
)]
\
+
mpi_flags
+
[
MPIEXEC_PREFLAG
,
str
(
exe
),
MPIEXEC_POSTFLAGS
]
+
list
(
args
)
if
k
]
def
run
(
args
):
if
not
os
.
path
.
isfile
(
args
[
"config"
]):
raise
IOError
(
"Configuration file {} not found"
.
format
(
args
[
"config"
]))
try
:
if
args
[
"parallel"
]
==
1
:
subprocess
.
check_call
([
DORIE_EXECUTABLE
,
args
[
"config"
]])
else
:
subprocess
.
check_call
(
MPIRUN
(
args
[
"parallel"
],
DORIE_EXECUTABLE
,
args
[
"config"
],
mpi_flags
=
args
[
"mpi_flags"
]))
except
subprocess
.
CalledProcessError
:
print
(
"Error while running DORiE"
)
sys
.
exit
(
1
)
def
create
(
args
):
for
f
in
(
"config.ini"
,
"parfield.ini"
,
"2d_infiltr.bcdat"
,
"3d_infiltr.bcdat"
):
newfile
=
os
.
path
.
join
(
os
.
getcwd
(),
f
)
if
os
.
path
.
exists
(
newfile
)
and
not
args
[
"force"
]:
override
=
(
input
(
"File {} exists. Override? [Y/n] "
.
format
(
f
))
or
"Y"
)
in
[
"Y"
,
"y"
]
if
not
override
:
continue
shutil
.
copyfile
(
os
.
path
.
join
(
PARAMETERDIR
,
f
),
newfile
)
print
(
"Folder initialized"
)
def
pfg
(
args
):
if
not
os
.
path
.
isfile
(
args
[
"config"
]):
raise
IOError
(
"Configuration file {} not found"
.
format
(
args
[
"config"
]))
try
:
if
args
[
"parallel"
]
==
1
:
subprocess
.
check_call
([
"pf_from_file.py"
,
args
[
"config"
]])
else
:
if
args
[
"mpi_flags"
]:
mpi_flags
=
[
"--mpi-flags="
+
f
for
f
in
args
[
"mpi_flags"
]]
else
:
mpi_flags
=
[]
subprocess
.
check_call
([
"pf_from_file.py"
,
args
[
"config"
],
"--parallel"
,
str
(
args
[
"parallel"
])]
+
mpi_flags
)
except
subprocess
.
CalledProcessError
:
print
(
"Error while running DORiE"
)
sys
.
exit
(
1
)
def
plot
(
args
):
if
not
os
.
path
.
isfile
(
args
[
"vtk"
]):
raise
IOError
(
"File {} not found"
.
format
(
args
[
"vtk"
]))
try
:
if
args
[
"var"
]:
subprocess
.
check_call
([
"plot_vtk.py"
,
"-f"
,
args
[
"vtk"
],
"--var"
,
args
[
"var"
]])
else
:
subprocess
.
check_call
([
"plot_vtk.py"
,
"-f"
,
args
[
"vtk"
]])
except
subprocess
.
CalledProcessError
:
print
(
"Error while running DORiE"
)
sys
.
exit
(
1
)
python/dorie/dorie/cli/parser.py
deleted
100644 → 0
View file @
69eb43f5
import
argparse
import
multiprocessing
# import all commands
from
.cmds
import
*
def
create_cl_parser
():
"""Create the command line parser for the DORiE CLI.
Returns:
ArgumentParser object for parsing the command line.
"""
parser
=
argparse
.
ArgumentParser
(
description
=
"DORiE Command Line Interface"
,
epilog
=
"For more information check our online documentation: "
"http://dorie-doc.netlify.com."
)
subparsers
=
parser
.
add_subparsers
(
title
=
"Commands"
,
dest
=
"command"
)
subparsers
.
required
=
True
parser_create
=
subparsers
.
add_parser
(
'create'
,
description
=
"Copy example configuration to current folder."
,
help
=
"Copy example configuration to current folder."
)
parser_create
.
add_argument
(
'-f'
,
'--force'
,
action
=
"store_true"
,
help
=
"Override existing files."
)
parser_create
.
set_defaults
(
func
=
create
)
parser_pfg
=
subparsers
.
add_parser
(
'pfg'
,
help
=
"Start parameter field generator."
,
description
=
"Start parameter field generator."
)
parser_pfg
.
add_argument
(
'config'
,
help
=
"Configuration file for the parameter field generator. "
"A default version can be created with 'dorie create'."
)
parser_pfg
.
add_argument
(
'-p'
,
'--parallel'
,
metavar
=
'N'
,
nargs
=
'?'
,
default
=
1
,
const
=
multiprocessing
.
cpu_count
(),
type
=
int
,
required
=
False
,
help
=
"Run in parallel on N processes. "
"If N is not specified, run on all available CPU threads."
)
parser_pfg
.
add_argument
(
'-m'
,
'--mpi-flags'
,
action
=
"append"
,
required
=
False
,
help
=
"Additional flags that are passed to mpirun when run in parallel. "
"May be specified multiple times."
)
parser_pfg
.
set_defaults
(
func
=
pfg
)
parser_run
=
subparsers
.
add_parser
(
'run'
,
help
=
"Run DORiE."
,
description
=
"Run DORiE."
)
parser_run
.
add_argument
(
'config'
,
help
=
"DORiE configuration file. "
"A default version can be created with 'dorie create'."
)
parser_run
.
add_argument
(
'-p'
,
'--parallel'
,
metavar
=
'N'
,
nargs
=
'?'
,
default
=
1
,
const
=
multiprocessing
.
cpu_count
(),
type
=
int
,
required
=
False
,
help
=
"Run in parallel on N processes. "
"If N is not specified, run on all available CPU threads."
)
parser_run
.
add_argument
(
'-m'
,
'--mpi-flags'
,
action
=
"append"
,
required
=
False
,
help
=
"Additional flags that are passed to mpirun when run in parallel. "
"May be specified multiple times."
)
parser_run
.
set_defaults
(
func
=
run
)
parser_plot
=
subparsers
.
add_parser
(
'plot'
,
help
=
"Plot a preview of a VTK file created by DORiE."
,
description
=
"Plot a preview of a VTK file created by DORiE."
)
parser_plot
.
add_argument
(
'vtk'
,
help
=
"Input VTK file."
)
parser_plot
.
add_argument
(
'-v'
,
'--var'
,
nargs
=
'*'
,
help
=
"Plot only given variables. If not specified, all variables are plotted."
)
parser_plot
.
set_defaults
(
func
=
plot
)
return
parser
\ No newline at end of file
python/dorie/setup.py
View file @
79a3cb0d
...
...
@@ -24,7 +24,6 @@ setup(name='dorie',
'wheel'
],
scripts
=
[
'wrapper/dorie'
,
'wrapper/pf_from_file.py'
,
'wrapper/plot_vtk.py'
,
'wrapper/scrape_folder.py'
,
...
...
python/dorie/wrapper/CMakeLists.txt
View file @
79a3cb0d
configure_file
(
dorie.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/dorie
)
configure_file
(
pf_from_file.py.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/pf_from_file.py
)
configure_file
(
test_dorie.py.in
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_dorie.py
)
\ No newline at end of file
python/dorie/wrapper/dorie.in
deleted
100644 → 0
View file @
69eb43f5
#!/usr/bin/env python3
import
sys
import
warnings
from
dorie.cli.parser
import
create_cl_parser
if
__name__
==
"__main__"
:
# parse command line and call command handler
try
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
warn
:
try
:
parser
=
create_cl_parser
()
args
=
parser
.
parse_args
()
except
SystemExit
:
sys
.
exit
(
1
)
args
.
func
(
vars
(
args
))
except
Exception
as
e
:
print
(
"dorie failed with ({0}) warning(s) and ({1}) error(s)"
.
format
(
len
(
warn
),
1
))
raise
python/dorie/wrapper/test_dorie.py.in
View file @
79a3cb0d
...
...
@@ -9,10 +9,14 @@ from dune.testtools.wrapper.argumentparser import get_args
from
dune.testtools.parser
import
parse_ini_file
from
dorie.testtools.wrapper
import
test_dorie
DORIE_WRAPPER
=
"dorie"
# paths set by cmake
DORIEDIR
=
"@CMAKE_BINARY_DIR@"
#
DORIE_WRAPPER
=
os
.
path
.
join
(
DORIEDIR
,
"bin/dorie"
)
if
__name__
==
"__main__"
:
args
=
get_args
()
iniargument
=
args
[
"ini"
]
iniinfo
=
parse_ini_file
(
args
[
"ini"
])
sys
.
exit
(
test_dorie
.
test_dorie
(
iniinfo
,
iniargument
,
DORIE_WRAPPER
))
sys
.
exit
(
test_dorie
.
test_dorie
(
iniinfo
,
iniargument
,
DORIE_WRAPPER
))
Lukas Riedel
@lriedel
mentioned in commit
b2185fcc
·
Sep 06, 2018
mentioned in commit
b2185fcc
mentioned in commit b2185fcc96bd96be5af8a096c8aae86593da0893
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment