Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kit/virtmat-tools/vre-language
1 result
Show changes
Commits on Source (18)
...@@ -34,30 +34,20 @@ The project can be installed into a Python virtual environment using the `pip` p ...@@ -34,30 +34,20 @@ The project can be installed into a Python virtual environment using the `pip` p
python -m pip install vre-language python -m pip install vre-language
``` ```
**NOTE: Broken install due to an open issue in FireWorks**
**NOTE: Broken install due to an issue in FireWorks** Fresh installations of VRE Language will currently *sometimes* not work. When running `texts` this error may occur
Fresh installations of VRE Language will currently *sometimes* not work. When running `texts` this error may occur:
``` ```
AttributeError: ModuleNotFoundError: No module named 'pytest'
"safe_load()" has been removed, use
yaml = YAML(typ='safe', pure=True)
yaml.load(...)
instead of file "jupyter-base-2024-05-14/lib64/python3.9/site-packages/fireworks/utilities/fw_serializers.py", line 256
dct = yaml.safe_load(f_str)
``` ```
This [issue](https://github.com/materialsproject/fireworks/issues/516) has been solved in FireWorks main branch but not yet released. See more discussions in this [issue](https://github.com/materialsproject/fireworks/issues/531). The error is documented in this [issue](https://github.com/materialsproject/fireworks/issues/535).
As a work-around, VRE Language tries to downgrade `ruamel.yaml` automatically. If downgrade of `ruamel.yaml <0.18.0` is not possible, for example when the `ruamel.yaml` package is installed system-wide, then the error above occurs when running `texts`. In this case, another non-automatic workaround has to be performed by the user. A fresh virtual environment has to be created (without fireworks, vre-language and vre-middleware). Then VRE Language is installed by the following two commands: As a work-around, the `pytest` package can be installed via this command:
``` ```
python -m pip install git+https://github.com/materialsproject/fireworks.git python -m pip install pytest
python -m pip install vre-language
``` ```
## Installation in developer (editable) mode ## Installation in developer (editable) mode
......
...@@ -14,7 +14,6 @@ The instructions for the quick installation and local database setup are: ...@@ -14,7 +14,6 @@ The instructions for the quick installation and local database setup are:
1. Install the VRE Language with the `mongomock` extra: 1. Install the VRE Language with the `mongomock` extra:
```bash ```bash
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install git+https://github.com/materialsproject/fireworks.git
python -m pip install "vre-language[mongomock]" python -m pip install "vre-language[mongomock]"
``` ```
......
...@@ -8,7 +8,7 @@ In the [*workflow* evaluation mode](tools.md#workflow-mode) it is possible to sp ...@@ -8,7 +8,7 @@ In the [*workflow* evaluation mode](tools.md#workflow-mode) it is possible to sp
## Granularity ## Granularity
Currently the evaluation's granularity of the workflow executor is determined by the amount of computations in the individial [variables](scl.md#variables) in the model source. The reason for this is that the interpreter maps variables to the *tasks* within a task graph which is used to construct a workflow. Currently the evaluation's granularity of the workflow executor is determined by the amount of computations in individual [variables](scl.md#variables). The reason for this is that the interpreter maps variables to *tasks* within a task graph which is used to construct a workflow.
**Rationale:** If a variable has several parameters, different from references to other variables, these will be executed on the same resources. This is beneficial only if no parameter or only one parameter requires a large amount of computation. If two or more parameters require high and different amounts of computation the granularity has to be decreased by splitting the statement into two or more statements such that in every statement maximum one parameter requires large computing resources (for example >95%). **Rationale:** If a variable has several parameters, different from references to other variables, these will be executed on the same resources. This is beneficial only if no parameter or only one parameter requires a large amount of computation. If two or more parameters require high and different amounts of computation the granularity has to be decreased by splitting the statement into two or more statements such that in every statement maximum one parameter requires large computing resources (for example >95%).
...@@ -87,6 +87,15 @@ In this example, `b` (which must be of [Series](scl.md#series) type) is split in ...@@ -87,6 +87,15 @@ In this example, `b` (which must be of [Series](scl.md#series) type) is split in
The interpreter will split the input data as much as possible into equally sized chunks. Nevertheless, if the number of data elements is not divisible by the number of chunks some of the chunks may have different number of elements. The interpreter will split the input data as much as possible into equally sized chunks. Nevertheless, if the number of data elements is not divisible by the number of chunks some of the chunks may have different number of elements.
## Resource configuration
[Resource annotation](#resource-annotation) enables constructing a *qadapter* object fully automatically by the interpreter. For this the interpreter uses the resource configuration created by the [VRE Middleware](https://vre-middleware.readthedocs.io/en/latest/resconfig.html). The configurations of computing resources and environment modules are captured fully automatically by running the [resconfig tool](https://vre-middleware.readthedocs.io/en/latest/resconfig_cli.html) but some settings specific for the *run-time environment* are not. These are:
* environment variables
* shell commands
* launch directory
These and all other configurations can be set or modified (using Python) as described [here](https://vre-middleware.readthedocs.io/en/latest/resconfig.html).
## Glossary ## Glossary
* [**Computing resource**](https://en.wikipedia.org/wiki/System_resource) requirement can be, for example, the number of processors, the size of memory and an estimate of the job running time. * [**Computing resource**](https://en.wikipedia.org/wiki/System_resource) requirement can be, for example, the number of processors, the size of memory and an estimate of the job running time.
......
...@@ -3,13 +3,12 @@ numpy ...@@ -3,13 +3,12 @@ numpy
pandas >=2.2.0 pandas >=2.2.0
pint >=0.24.3 pint >=0.24.3
pint-pandas ==0.6.2 pint-pandas ==0.6.2
fireworks >=2.0.3 fireworks >=2.0.4
pyyaml pyyaml
dill dill
ase >=3.23.0 ase >=3.23.0
seaborn seaborn
vre-middleware >=1.2.1 vre-middleware >=1.2.2
jupyter_client jupyter_client
ipykernel ipykernel
ruamel.yaml <0.18.0
pympler pympler
...@@ -39,15 +39,14 @@ install_requires = ...@@ -39,15 +39,14 @@ install_requires =
pandas >=2.2.0 pandas >=2.2.0
pint >=0.24.3 pint >=0.24.3
pint-pandas ==0.7.1 pint-pandas ==0.7.1
fireworks >=2.0.3 fireworks >=2.0.4
pyyaml pyyaml
dill dill
ase >=3.23.0 ase >=3.23.0
seaborn seaborn
vre-middleware >=1.2.1 vre-middleware >=1.2.2
jupyter_client jupyter_client
ipykernel ipykernel
ruamel.yaml <0.18.0
pympler pympler
[options.extras_require] [options.extras_require]
......
...@@ -23,7 +23,7 @@ from virtmat.language.utilities.formatters import formatter ...@@ -23,7 +23,7 @@ from virtmat.language.utilities.formatters import formatter
from virtmat.language.utilities.errors import textxerror_wrap, error_handler from virtmat.language.utilities.errors import textxerror_wrap, error_handler
from virtmat.language.utilities.errors import SubscriptingError, PropertyError from virtmat.language.utilities.errors import SubscriptingError, PropertyError
from virtmat.language.utilities.errors import InvalidUnitError, RuntimeValueError from virtmat.language.utilities.errors import InvalidUnitError, RuntimeValueError
from virtmat.language.utilities.errors import RuntimeTypeError from virtmat.language.utilities.errors import RuntimeTypeError, TEXTX_WRAPPED_EXCEPTIONS
from virtmat.language.utilities.typemap import typemap, checktype, checktype_ from virtmat.language.utilities.typemap import typemap, checktype, checktype_
from virtmat.language.utilities.typemap import is_table_like_type, is_table_like from virtmat.language.utilities.typemap import is_table_like_type, is_table_like
from virtmat.language.utilities.types import is_array, is_scalar, settype from virtmat.language.utilities.types import is_array, is_scalar, settype
...@@ -110,13 +110,17 @@ def type_func(self): ...@@ -110,13 +110,17 @@ def type_func(self):
and callable(get_object_import(par.ref)) or not numeric): and callable(get_object_import(par.ref)) or not numeric):
return (lambda: typemap['Table']([dct]), tuple()) return (lambda: typemap['Table']([dct]), tuple())
assert numeric assert numeric
func, pars = par.func
def retfunc(val): def retfunc(*args):
dct['dimensionality'] = str(get_dimensionality(val)) try:
dct['units'] = str(get_units(val)) val = func(*args)
dct['dimensionality'] = str(get_dimensionality(val))
dct['units'] = str(get_units(val))
except TEXTX_WRAPPED_EXCEPTIONS:
pass
return typemap['Table']([dct]) return typemap['Table']([dct])
func, pars = par.func return retfunc, pars
return (lambda *x: retfunc(func(*x)), pars)
def variable_func(self): def variable_func(self):
......
...@@ -10,6 +10,7 @@ import numpy ...@@ -10,6 +10,7 @@ import numpy
import pint_pandas import pint_pandas
from pint.errors import PintError from pint.errors import PintError
from textx import get_children_of_type, get_parent_of_type from textx import get_children_of_type, get_parent_of_type
from textx.exceptions import TextXError
from virtmat.language.constraints.imports import get_object_import from virtmat.language.constraints.imports import get_object_import
from virtmat.language.metamodel.function import subst from virtmat.language.metamodel.function import subst
from virtmat.language.utilities.textx import isinstance_m from virtmat.language.utilities.textx import isinstance_m
...@@ -158,8 +159,11 @@ def type_value(self): ...@@ -158,8 +159,11 @@ def type_value(self):
'numeric': numeric, 'numeric': numeric,
'datatype': get_datatype_name(datatype)} 'datatype': get_datatype_name(datatype)}
if numeric: if numeric:
dct['dimensionality'] = str(get_dimensionality(par.value)) try:
dct['units'] = str(get_units(par.value)) dct['dimensionality'] = str(get_dimensionality(par.value))
dct['units'] = str(get_units(par.value))
except TextXError:
pass
return typemap['Table']([dct]) return typemap['Table']([dct])
......
...@@ -241,10 +241,10 @@ class SessionManager(InteractiveConsole): ...@@ -241,10 +241,10 @@ class SessionManager(InteractiveConsole):
wfs = self.get_wflows_from_user_query(q_dict) wfs = self.get_wflows_from_user_query(q_dict)
if model.load_one: if model.load_one:
wf_uuids = [wf['metadata']['uuid'] for wf in wfs] wf_uuids = [wf['metadata']['uuid'] for wf in wfs]
if self.uuid not in wf_uuids: if wf_uuids and self.uuid not in wf_uuids:
self.switch_model(wf_uuids[0]) self.switch_model(wf_uuids[0])
print('uuids:', formatter(self.uuid), formatter(self.session.uuids)) print('uuids:', formatter(self.uuid), formatter(self.session.uuids))
else: elif wfs:
lines = [] lines = []
for wf in wfs: for wf in wfs:
lines.append(' '.join((f'{wf["state"]:10}', lines.append(' '.join((f'{wf["state"]:10}',
......
...@@ -309,10 +309,14 @@ def type_value(self): ...@@ -309,10 +309,14 @@ def type_value(self):
if (isinstance_m(par, ['GeneralReference']) and isinstance_m(par.ref, ['ObjectImport']) if (isinstance_m(par, ['GeneralReference']) and isinstance_m(par.ref, ['ObjectImport'])
and callable(get_object_import(par.ref))): and callable(get_object_import(par.ref))):
return pandas.DataFrame([dct]) return pandas.DataFrame([dct])
parval = get_par_value(par) try:
if parval is not NC and is_numeric(parval): parval = get_par_value(par)
dct['dimensionality'] = str(get_dimensionality(parval)) except TextXError:
dct['units'] = str(get_units(parval)) pass
else:
if parval is not NC and is_numeric(parval):
dct['dimensionality'] = str(get_dimensionality(parval))
dct['units'] = str(get_units(parval))
if (isinstance_m(par, ['GeneralReference']) if (isinstance_m(par, ['GeneralReference'])
and not isinstance_m(par.ref, ['ObjectImport'])): and not isinstance_m(par.ref, ['ObjectImport'])):
model = get_model(self) model = get_model(self)
......
...@@ -22,7 +22,7 @@ spec = { ...@@ -22,7 +22,7 @@ spec = {
'module': 'ase.calculators.vasp', 'module': 'ase.calculators.vasp',
'class': 'Vasp', 'class': 'Vasp',
'modulefile': {'name': 'vasp', 'verspec': '>=5.0.0'}, 'modulefile': {'name': 'vasp', 'verspec': '>=5.0.0'},
'envvars': {'VASP_COMMAND': '"$DO_PARALLEL $VASP_MPI"'}, 'envvars': {'VASP_COMMAND': 'vasp_std'},
'properties': ['energy', 'dipole', 'forces', 'stress', 'vibrational_energies', 'properties': ['energy', 'dipole', 'forces', 'stress', 'vibrational_energies',
'energy_minimum', 'transition_state', 'trajectory', 'magmom', 'energy_minimum', 'transition_state', 'trajectory', 'magmom',
'magmoms'] 'magmoms']
......
...@@ -21,15 +21,24 @@ def launchdir(tmp_dir): ...@@ -21,15 +21,24 @@ def launchdir(tmp_dir):
def run_fireworks(lpad, fw_ids, worker_name=None, create_subdirs=False): def run_fireworks(lpad, fw_ids, worker_name=None, create_subdirs=False):
"""launch fireworks with the provided fw_ids""" """launch fireworks with the provided fw_ids"""
worker = FWorker(name=worker_name, query={'fw_id': {'$in': fw_ids}}) fw_query = {'fw_id': {'$in': fw_ids}}
launch_kwargs = {'strm_lvl': lpad.strm_lvl}
launch_kwargs['fworker'] = FWorker(name=worker_name, query=fw_query)
cfg = get_default_resconfig() cfg = get_default_resconfig()
default_launchdir = cfg and cfg.default_worker.default_launchdir if cfg:
with launchdir(default_launchdir or os.getcwd()): if worker_name:
wcfg = next(w for w in cfg.workers if w.name == worker_name)
else:
wcfg = cfg.default_worker
default_launchdir = wcfg.default_launchdir or os.getcwd()
else:
default_launchdir = os.getcwd()
with launchdir(default_launchdir):
if create_subdirs: if create_subdirs:
rapidfire(lpad, fworker=worker, nlaunches=0, strm_lvl=lpad.strm_lvl) rapidfire(lpad, nlaunches=0, local_redirect=True, **launch_kwargs)
else: else:
for _ in fw_ids: for _ in fw_ids:
launch_rocket(lpad, fworker=worker, strm_lvl=lpad.strm_lvl) launch_rocket(lpad, **launch_kwargs)
def get_nodes_providing(lpad, uuid, name): def get_nodes_providing(lpad, uuid, name):
......
...@@ -398,7 +398,7 @@ def test_amml_property_resources(meta_model_wf, model_kwargs_wf, _res_config_loc ...@@ -398,7 +398,7 @@ def test_amml_property_resources(meta_model_wf, model_kwargs_wf, _res_config_loc
"prop = Property energy, forces ((structure: h2o), (calculator: calc))" "prop = Property energy, forces ((structure: h2o), (calculator: calc))"
" on 4 cores for 0.1 [hour]") " on 4 cores for 0.1 [hour]")
pre_rocket = ('module purge; module use null; module load chem/vasp/5.4.4.pl2; ' pre_rocket = ('module purge; module use null; module load chem/vasp/5.4.4.pl2; '
'export VASP_COMMAND="$DO_PARALLEL $VASP_MPI"') 'export VASP_COMMAND=vasp_std')
prog = meta_model_wf.model_from_str(inp, **model_kwargs_wf) prog = meta_model_wf.model_from_str(inp, **model_kwargs_wf)
var_list = get_children_of_type('Variable', prog) var_list = get_children_of_type('Variable', prog)
var = next(v for v in var_list if v.name == 'prop') var = next(v for v in var_list if v.name == 'prop')
......
...@@ -548,6 +548,17 @@ def test_builtin_type_function(meta_model, model_kwargs): ...@@ -548,6 +548,17 @@ def test_builtin_type_function(meta_model, model_kwargs):
assert typ.value.units.tolist() == ['meter'] assert typ.value.units.tolist() == ['meter']
def test_builtin_type_function_with_eval_error(meta_model, model_kwargs, test_config):
"""test the built-in type function with evaluation error"""
prog_inp = "a = 2 / 0; print(type(a))"
prog = meta_model.model_from_str(prog_inp, **model_kwargs)
ref = ("((name: 'a'), (type: 'Quantity'), (scalar: true), (numeric: true),"
" (datatype: 'float')")
if test_config[1] or not test_config[0]:
# fixme: deferred will work only with non-strict eval
assert ref in prog.value
def test_builtin_type_function_callable_import(meta_model, model_kwargs): def test_builtin_type_function_callable_import(meta_model, model_kwargs):
"""test the built-in type function with callable import""" """test the built-in type function with callable import"""
prog_inp = "use random from numpy.random; print(type(random))" prog_inp = "use random from numpy.random; print(type(random))"
......