Skip to content

Commit

Permalink
Remove m as dependency on linux
Browse files Browse the repository at this point in the history
Add debug message for compilation of dependencies
Try using the conda-forge default fortran compiler on windows
Fix debug message in connection driver
Attempt to fix tool usage for OSR model driver
Add debug message prior to segfault that occurs on linux in normalization
Updated python-rapidjson
Fix use of deprecated matplotlib.cm.get_cmap
  • Loading branch information
langmm committed Jun 20, 2024
1 parent a904acf commit e94ad61
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 44 deletions.
4 changes: 1 addition & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ outputs:
- python
run:
- {{ pin_subpackage('yggdrasil.c', exact=True) }}
- m2w64-gcc-fortran # [win]
- m2w64-toolchain_win-64 # [win]
- {{ compiler('fortran') }} # [not win]
- {{ compiler('fortran') }}
- name: yggdrasil.r
build:
string: py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
Expand Down
12 changes: 1 addition & 11 deletions utils/requirements/requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,12 @@
"gfortran": [
{
"name": "{{ compiler('fortran') }}",
"method": "conda_recipe",
"os": "unix"
"method": "conda_recipe"
},
{
"name": "fortran-compiler",
"os": "unix",
"method": "conda"
},
{
"name": "m2w64-gcc-fortran",
"os": "win",
"method": "conda",
"add": [
"m2w64-toolchain_win-64"
]
},
{
"name": "gfortran",
"method": "apt"
Expand Down
12 changes: 6 additions & 6 deletions utils/requirements/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ extras:
- gfortran:
- name: "{{ compiler('fortran') }}"
method: conda_recipe
os: unix
# os: unix
- name: fortran-compiler
os: unix
# os: unix
method: conda
- name: m2w64-gcc-fortran
os: win
method: conda
add: [m2w64-toolchain_win-64]
# - name: m2w64-gcc-fortran
# os: win
# method: conda
# add: [m2w64-toolchain_win-64]
- name: gfortran
method: apt
- name: gfortran
Expand Down
4 changes: 1 addition & 3 deletions utils/requirements/requirements_condaonly.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
cmake; platform_system != 'Windows' # [conda,c]
compiler-rt; platform_system == 'Darwin' # [conda,c]
czmq # [conda,zmq]
fortran-compiler; platform_system != 'Windows' # [conda,fortran]
fortran-compiler # [conda,fortran]
ghostscript # [conda,images]
git # [conda]
juliaup # [conda,julia]
lz4 # [conda,zmq]
m2w64-gcc-fortran; platform_system == 'Windows' # [conda,fortran]
m2w64-toolchain_win-64; platform_system == 'Windows' # [conda,fortran]
make; platform_system != 'Windows' # [conda,c]
matplotlib-base # [conda]
mpich; platform_system == 'Linux' # [conda,mpi]
Expand Down
2 changes: 1 addition & 1 deletion yggdrasil/drivers/CModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class CModelDriver(CompiledModelDriver):
'platform_specifics': {
'Linux': {
'compiler_flags': ['-fPIC'],
'external_dependencies': ['m'],
# 'external_dependencies': ['m'],
},
'Windows': {
'include_dirs': [_top_lang_dir],
Expand Down
32 changes: 23 additions & 9 deletions yggdrasil/drivers/CompiledModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ def remainder(cls, kwargs, remove_parameters=False):
return out

def __str__(self):
return str(self._tuple)
return str({k: self[k] for k in self.defaults.keys()})

def __repr__(self):
return f"DependencySpecialization({str(self)})"
Expand Down Expand Up @@ -2356,6 +2356,26 @@ def __repr__(self):
return (f"CompilationDependency({self.name}, "
f"driver={self.parent_driver.language})")

def logInfo(self, level=logging.INFO, tooltype='basetool'):
r"""Display info abou the dependency as an info level log message."""
specinfo = pprint.pformat({k: self.specialization[k] for k in
self.specialization.defaults.keys()})
specinfo = specinfo.replace('\n', '\n' + 16 * ' ')
toolinfo = pprint.pformat({k: self.toolname(k) for k in
self.active_tools()})
toolinfo = toolinfo.replace('\n', '\n' + 16 * ' ')
tool = self.tool(tooltype)
src = self.get(f'{tool.tooltype}_input')
logger.log(level,
f"\n"
f" dependency: {self.name}\n"
f" driver: {self.parent_driver.language}\n"
f" spec: {specinfo}\n"
f" libtype: {self['libtype']}\n"
f" input: {src}\n"
f" output: {self.result}\n"
f" tooltypes: {toolinfo}")

def set(self, filetype, value, key=None):
r"""Set a library file path.
Expand Down Expand Up @@ -3337,14 +3357,7 @@ def build(self, tooltype='basetool', no_additional_stages=False,
# Recursion can occur if the dependencies are not actually
# being compiled or there is a mismatch in the path to
# a compiled dependency and the path used by dependents
tooltypes = self.active_tools()
toolnames = [self.toolname(k) for k in tooltypes]
logger.error(f"dependency: {self.name}\n"
f"libtype: {self['libtype']}\n"
f"input: {src}\n"
f"output: {self.result}\n"
f"tooltypes: {tooltypes}\n"
f"toolnames: {toolnames}")
self.logInfo(level=logging.ERROR)
kwargs['products'].teardown(tag='build_time')
kwargs['products'].teardown()
raise
Expand Down Expand Up @@ -6939,6 +6952,7 @@ def compile_dependencies(cls, dep=None, **kwargs):
dep = cls.libraries[dep].specialized(**kwargs)
kwargs.update(preserved_kwargs)
dep.build(**kwargs)
dep.logInfo()

@classmethod
def cleanup_dependencies(cls, dep=None, products=None,
Expand Down
6 changes: 3 additions & 3 deletions yggdrasil/drivers/ConnectionDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ def remove_model(self, direction, name):
if name in self.models[direction]:
self.models[direction].remove(name)
self.debug(
"{direction.title()} model '{name}' signed off."
"\n\tInput models: {len(self.models['input'])}"
"\n\tOutput models: {len(self.models['output'])}")
f"{direction.title()} model '{name}' signed off."
f"\n\tInput models: {self.models['input']}"
f"\n\tOutput models: {self.models['output']}")
out = (out or (len(self.models[direction]) == 0))
opp_direction = 'output' if direction == 'input' else 'input'
if out and name in self.models[opp_direction]:
Expand Down
14 changes: 8 additions & 6 deletions yggdrasil/drivers/OSRModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,21 @@ def compile_dependencies(cls, target='OpenSimRootYgg', toolname=None,
if not os.path.isdir(cls.repository): # pragma: debug
# This will only need to be called if the tempdir was cleaned up
cls.clone_repository(cls.repository)
# toolname = CPPModelDriver.get_tool('compiler',
# return_prop='name',
# default=None)
if toolname is None:
toolname = CPPModelDriver.get_tool('compiler',
return_prop='name',
default=None)
logger.info(f"OSR C++ compiler: {toolname}")
cwd = os.path.join(cls.repository, 'OpenSimRoot')
flags = []
if maxjobs > 1:
flags += [f'-j{maxjobs}']
env = copy.deepcopy(os.environ)
if platform._is_win: # pragma: windows
toolname = 'cl'
# toolname = 'cl++'
env['YGG_OSR_TOOL'] = toolname
if toolname == 'cl':
cl_path = shutil.which(toolname + '.exe')
if toolname == 'cl++':
cl_path = shutil.which('cl.exe')
if cl_path:
msvc_bin = os.path.dirname(cl_path)
env['YGG_OSR_CXX'] = cl_path
Expand Down
2 changes: 1 addition & 1 deletion yggdrasil/python-rapidjson
Submodule python-rapidjson updated 1 files
+11 −0 units.cpp
4 changes: 3 additions & 1 deletion yggdrasil/serialize/PlySerialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def apply_scalar_map(self, scalar_arr, color_map=None,
"""
from matplotlib import cm
from matplotlib import colors as mpl_colors
from matplotlib import colormaps as mpl_colormaps
# Scale by area
if scale_by_area:
areas = np.array(self.areas)
Expand Down Expand Up @@ -221,7 +222,8 @@ def apply_scalar_map(self, scalar_arr, color_map=None,
assert isinstance(vmax, np.ma.core.MaskedConstant)
vertex_colors = np.zeros((len(vertex_scalar), 3), 'int')
else:
cmap = cm.get_cmap(color_map)
cmap = mpl_colormaps[color_map]
# cmap = cm.get_cmap(color_map)
if scaling == 'log':
norm = mpl_colors.LogNorm(vmin=vmin, vmax=vmax)
elif scaling == 'linear':
Expand Down
4 changes: 4 additions & 0 deletions yggdrasil/serialize/SerializeBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ def get_testing_options(cls, table_example=False, array_columns=False,
arr = np.array(rows, dtype=dtype)
if no_names:
arr = [arr[n] for n in arr.dtype.names]
import pprint
print("BEFORE POSSIBLE SEGFAULT")
pprint.pprint(arr)
pprint.pprint(out['datatype'])
lst = rapidjson.normalize(arr, out['datatype'])
out['objects'] = [lst, lst]
else:
Expand Down

0 comments on commit e94ad61

Please sign in to comment.