Skip to content
Draft
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
470e1e7
Adds automated codecov support to Hatchet
ilumsden May 23, 2024
029e147
Bumps Python version for black and flake checks to 3.9 to ensure tool…
ilumsden May 23, 2024
e78da99
Initial changes
ilumsden May 23, 2024
ca108fc
Sets gitattributes to not capture tests directory in dist
ilumsden May 23, 2024
d4b7791
Further updates to gitattributes and gitignore
ilumsden May 23, 2024
26f7493
Spelling fix
ilumsden May 23, 2024
0af93d1
Current progress
ilumsden May 23, 2024
60e2f8c
Gets a fully working package with meson-python
ilumsden May 23, 2024
d5a76c9
Removes 'meson[ninja]' from pyproject.toml's build-system.requires si…
ilumsden May 23, 2024
f101329
Cleans up metadata in pyproject.toml
ilumsden May 23, 2024
cbfe0d2
Adds a check to the top-level meson.build to ensure the version in ve…
ilumsden May 23, 2024
60b1e11
Adds comments
ilumsden May 23, 2024
e2ff223
Adds extra for HDF5 writer
ilumsden May 23, 2024
38d4500
Tweaks CI to install Hatchet locally with pip
ilumsden May 23, 2024
43a9955
Fixes license headers
ilumsden May 23, 2024
ccddb5f
Formatting fix
ilumsden May 23, 2024
0c9eb9d
Formatting to make flake happy
ilumsden May 23, 2024
ecde7ba
Adds ninja extra to build requirements for Hatchet
ilumsden May 23, 2024
70b2c6b
Adds script for editable installs and tries not using editable in uni…
ilumsden May 23, 2024
2feaace
Adds tables extra to install of Hatchet in CI
ilumsden May 23, 2024
4daea24
Fixes the extra name in CI
ilumsden May 23, 2024
fce6d47
Merge branch 'develop' into meson_build_sys
ilumsden May 24, 2024
fb08595
Update .gitattributes
ilumsden May 24, 2024
1f9199b
Update pyproject.toml
ilumsden May 24, 2024
2b2e54f
Drops the version check on the textx dependency since that check will…
ilumsden May 24, 2024
f52430d
Deletes install.sh since it will no longer work
ilumsden May 24, 2024
407ef1a
Adds some arguments to find_installation to try to restrict lookup
ilumsden May 24, 2024
a038611
Updates top level meson.build to get version from Hatchet's Python code
ilumsden May 28, 2024
670ab8a
Removes the hatchet.__version__ check as it is now redundant
ilumsden May 28, 2024
e067ae1
Small syntax fix
ilumsden May 28, 2024
66d5d81
Tries to get print_version.py running
ilumsden May 28, 2024
8e92bc5
Reverts the version stuff in meson since running print_version.py isn…
ilumsden May 28, 2024
952efa7
A few attempted fixes
ilumsden Jun 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ max-line-length = 88
select = C,E,F,W,B,B950
ignore = E501,W503,E203
builtins = IPython
exclude =
build
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
hatchet/tests export-ignore
screenshot.png export-ignore
pytest.ini export-ignore
logo.png export-ignore
logo-hex.png export-ignore
install.sh export-ignore
CHANGELOG.md export-ignore
.pre-commit-config.yaml export-ignore
.flake8 export-ignore
.coveragerc export-ignore
.codecov.yml export-ignore
docs export-ignore
.github export-ignore
12 changes: 4 additions & 8 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python3 dependencies
- name: Install Hatchet
run: |
python -m pip install --upgrade pip pytest
pip install -r requirements.txt
# Optional Dependency for HDF Checkpointing
pip install tables
python setup.py install
python setup.py build_ext --inplace
python -m pip list
python -m pip install .[hdf_writer]

- name: Update Black
if: ${{ matrix.python-version == 3.9 }}
Expand Down Expand Up @@ -91,7 +86,8 @@ jobs:

- name: Test Caliper and Timemory Support with pytest
run: |
PYTHONPATH=. $(which pytest) --cov=./ --cov-report=xml
# PYTHONPATH=. $(which pytest) --cov=./ --cov-report=xml
$(which pytest) --cov=./ --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ hatchet/vis/static/*_bundle*

dist/
llnl_hatchet.egg-info/
**/__pycache__/
17 changes: 17 additions & 0 deletions hatchet/cython_modules/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Specify the names of the Cython extension modules, excluding file extensions
cython_module_names = [
'graphframe_modules',
'reader_modules'
]

# Loop over the Cython modules and build/install them to
# <INSTALL_PREFIX>/hatchet/cython_modules/libs
foreach mod_name : cython_module_names
py.extension_module(
mod_name,
mod_name + '.pyx',
dependencies: py_dep,
subdir: 'hatchet' / 'cython_modules' / 'libs',
install: true
)
endforeach
20 changes: 20 additions & 0 deletions hatchet/external/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Specify the pure Python files for this directory
hatchet_external_python_sources = [
'__init__.py',
'console.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/external
py.install_sources(
hatchet_external_python_sources,
pure: false,
subdir: 'hatchet' / 'external'
)

# Install roundtrip as-is into
# <INSTALL_PREFIX>/hatchet/external
install_subdir(
'roundtrip',
install_dir: py_top_install_dir / 'hatchet' / 'external'
)
26 changes: 26 additions & 0 deletions hatchet/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Specify the pure Python files for this directory
hatchet_python_sources = [
'__init__.py',
'frame.py',
'graph.py',
'graphframe.py',
'node.py',
'version.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet
py.install_sources(
hatchet_python_sources,
pure: false,
subdir: 'hatchet'
)

# Go through all the subdirectories except for 'test'
subdir('cython_modules')
subdir('external')
subdir('query')
subdir('readers')
subdir('util')
subdir('vis')
subdir('writers')
19 changes: 19 additions & 0 deletions hatchet/query/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Specify the pure Python files for this directory
hatchet_query_python_sources = [
'__init__.py',
'compat.py',
'compound.py',
'engine.py',
'errors.py',
'object_dialect.py',
'query.py',
'string_dialect.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/query
py.install_sources(
hatchet_query_python_sources,
pure: false,
subdir: 'hatchet' / 'query'
)
25 changes: 25 additions & 0 deletions hatchet/readers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Specify the pure Python files for this directory
hatchet_readers_python_sources = [
'__init__.py',
'caliper_native_reader.py',
'caliper_reader.py',
'cprofile_reader.py',
'dataframe_reader.py',
'gprof_dot_reader.py',
'hdf5_reader.py',
'hpctoolkit_reader.py',
'json_reader.py',
'literal_reader.py',
'pyinstrument_reader.py',
'spotdb_reader.py',
'tau_reader.py',
'timemory_reader.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/readers
py.install_sources(
hatchet_readers_python_sources,
pure: false,
subdir: 'hatchet' / 'readers'
)
2 changes: 1 addition & 1 deletion hatchet/tests/query_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2022 Lawrence Livermore National Security, LLC and other
# Copyright 2017-2023 Lawrence Livermore National Security, LLC and other
# Hatchet Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT
Expand Down
21 changes: 21 additions & 0 deletions hatchet/util/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Specify the pure Python files for this directory
# Note: don't include 'print_version.py' because
# that file is not needed in binary distributions
hatchet_util_python_sources = [
'__init__.py',
'colormaps.py',
'config.py',
'deprecated.py',
'dot.py',
'executable.py',
'profiler.py',
'timer.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/util
py.install_sources(
hatchet_util_python_sources,
pure: false,
subdir: 'hatchet' / 'util'
)
13 changes: 13 additions & 0 deletions hatchet/util/print_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2017-2023 Lawrence Livermore National Security, LLC and other
# Hatchet Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT

import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from version import __version__ # noqa: E402

print(__version__)
47 changes: 47 additions & 0 deletions hatchet/vis/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Specify the pure Python files for this directory
hatchet_vis_python_sources = [
'__init__.py',
'loader.py',
'static_fixer.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/vis
py.install_sources(
hatchet_vis_python_sources,
pure: false,
subdir: 'hatchet' / 'vis'
)

# Install directory for this source directory
hatchet_vis_install_dir = py_top_install_dir / 'hatchet' / 'vis'

# Install all the subdirectories for visualization code as-is
# into hatchet_vis_install_dir
install_subdir(
'external',
install_dir: hatchet_vis_install_dir
)
install_subdir(
'scripts',
install_dir: hatchet_vis_install_dir
)
install_subdir(
'static',
install_dir: hatchet_vis_install_dir
)
install_subdir(
'styles',
install_dir: hatchet_vis_install_dir
)
install_subdir(
'templates',
install_dir: hatchet_vis_install_dir
)

# Install the following non-Python files as-is
# into hatchet_vis_install_dir
install_data(
'package.json', 'README.md', 'requirements.txt', 'webpack.config.js',
install_dir: hatchet_vis_install_dir
)
14 changes: 14 additions & 0 deletions hatchet/writers/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Specify the pure Python files for this directory
hatchet_writers_python_sources = [
'__init__.py',
'dataframe_writer.py',
'hdf5_writer.py'
]

# Install the specified pure Python files into
# <INSTALL_PREFIX>/hatchet/writers
py.install_sources(
hatchet_writers_python_sources,
pure: false,
subdir: 'hatchet' / 'writers'
)
5 changes: 5 additions & 0 deletions install_editable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

python3 -m pip install meson[ninja] meson-python Cython

python3 -m pip install --no-build-isolation -e .
23 changes: 23 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Setup the Meson Project
project('llnl-hatchet', 'cython',
version: '2024.1.1'
)

# Get the Meson Python object, a dependency object to Python for extension modules,
# and the path to the top-level install directory
py = import('python').find_installation(pure: false)
py_dep = py.dependency()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to note that I was able to build hatchet with meson on Quartz using conda and python 3.11.9. But when trying on local (Windows) using conda (python 3.11.9), I get the following error on this line:

$ pip install hatchet-meson/
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Processing c:\users\micha\documents\github\hatchet-meson
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  Preparing metadata (pyproject.toml) did not run successfully.
  exit code: 1

  [18 lines of output]
  + meson setup C:\Users\Micha\Documents\Github\hatchet-meson C:\Users\Micha\Documents\Github\hatchet-meson\.mesonpy-dnom1o2_ -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\Micha\Documents\Github\hatchet-meson\.mesonpy-dnom1o2_\meson-python-native-file.ini
  The Meson build system
  Version: 1.4.0
  Source dir: C:\Users\Micha\Documents\Github\hatchet-meson
  Build dir: C:\Users\Micha\Documents\Github\hatchet-meson\.mesonpy-dnom1o2_
  Build type: native build
  Project name: llnl-hatchet
  Project version: 2024.1.1
  Activating VS 16.11.26
  Cython compiler for the host machine: cython (cython 3.0.10)
  Host machine cpu family: x86_64
  Host machine cpu: x86_64
  Program python found: YES (C:\Users\Micha\miniconda3\envs\test-meson\python.exe)
  Run-time dependency python found: NO

  ..\meson.build:9:12: ERROR: Python dependency not found

  A full log can be found at C:\Users\Micha\Documents\Github\hatchet-meson\.mesonpy-dnom1o2_\meson-logs\meson-log.txt
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Same error If i run . install_editable.sh. I was able to install this way with setuptools.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions related to this @michaelmckinsey1:

  1. Do you have pkgconfig installed?
  2. Where are your Python development libraries (i.e., libpython<version_stuff>.so) installed?

Long story short, this is essentially caused by Windows being different from every other OS on the planet and doing certain things differently from every other OS.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelmckinsey1 when you get the chance, can you try to download and install the following sdist in a Python venv?

https://files.pythonhosted.org/packages/65/6e/09db70a523a96d25e115e71cc56a6f9031e7b8cd166c1ac8438307c14058/numpy-1.26.4.tar.gz

Once the file is downloaded, you can install with

python3 -m pip install numpy-1.26.4.tar.gz

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if that will fail with the same error. From what I can tell, the Python lookup Meson code is the same as what NumPy uses. If installing that sdist fails too, then there's likely an issue with your Windows install of Python. But, if it doesn't, then there's something wrong with my Meson stuff in Hatchet.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I did not have pkgconfig, but installing it did not fix the issue.
  2. They would be .dll not .so right? I don't even see any libpython*.dll, all I see in conda is:
miniconda3/envs/test-meson/Lib/site-packages/Cython/Debugger/libpython.py
miniconda3/envs/test-meson/Lib/site-packages/Cython/Debugger/Tests/test_libpython_in_gdb.py
miniconda3/envs/test-meson/Lib/site-packages/Cython/Debugger/Tests/__pycache__/test_libpython_in_gdb.cpython-311.pyc
miniconda3/envs/test-meson/Lib/site-packages/Cython/Debugger/__pycache__/libpython.cpython-311.pyc
  1. I tried downloading the sdist and still got the same error

I also tried with venv, and I tried on another windows device with conda, same error. I would assume for now it's a general issue with our meson build for Windows, unless someone else is able to successfully build on Windows.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelmckinsey1 can you run python3 -m sysconfig and paste the output here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I can now reproduce on macOS when pkgconfig is not installed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ python -m sysconfig
Platform: "win-amd64"
Python version: "3.11"
Current installation scheme: "nt"

Paths:
        data = "C:\Users\Micha\miniconda3\envs\test-meson"
        include = "C:\Users\Micha\miniconda3\envs\test-meson\Include"
        platinclude = "C:\Users\Micha\miniconda3\envs\test-meson\Include"
        platlib = "C:\Users\Micha\miniconda3\envs\test-meson\Lib\site-packages"
        platstdlib = "C:\Users\Micha\miniconda3\envs\test-meson\Lib"
        purelib = "C:\Users\Micha\miniconda3\envs\test-meson\Lib\site-packages"
        scripts = "C:\Users\Micha\miniconda3\envs\test-meson\Scripts"
        stdlib = "C:\Users\Micha\miniconda3\envs\test-meson\Lib"

Variables:
        BINDIR = "C:\Users\Micha\miniconda3\envs\test-meson"
        BINLIBDEST = "C:\Users\Micha\miniconda3\envs\test-meson\Lib"
        EXE = ".exe"
        EXT_SUFFIX = ".cp311-win_amd64.pyd"
        INCLUDEPY = "C:\Users\Micha\miniconda3\envs\test-meson\Include"
        LIBDEST = "C:\Users\Micha\miniconda3\envs\test-meson\Lib"
        TZPATH = "C:\Users\Micha\miniconda3\envs\test-meson\share\zoneinfo"
        VERSION = "311"
        VPATH = "..\.."
        abiflags = ""
        base = "C:\Users\Micha\miniconda3\envs\test-meson"
        exec_prefix = "C:\Users\Micha\miniconda3\envs\test-meson"
        installed_base = "C:\Users\Micha\miniconda3\envs\test-meson"
        installed_platbase = "C:\Users\Micha\miniconda3\envs\test-meson"
        platbase = "C:\Users\Micha\miniconda3\envs\test-meson"
        platlibdir = "DLLs"
        prefix = "C:\Users\Micha\miniconda3\envs\test-meson"
        projectbase = "C:\Users\Micha\miniconda3\envs\test-meson"
        py_version = "3.11.9"
        py_version_nodot = "311"
        py_version_nodot_plat = "311"
        py_version_short = "3.11"
        srcdir = "C:\Users\Micha\miniconda3\envs\test-meson"
        userbase = "C:\Users\Micha\AppData\Roaming\Python"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've worked this out. For some (stupid) reason, Meson never tries to use Python's sysconfig library to locate the development libraries or include dirs. Meson has 2 lookup modes for the Python dependency:

  1. pkgconfig: invokes pkg-config to locate the libraries. Will fail if pkg-config is not installed (unlikely on Linux, but likely on macOS and Windows), if PKG_CONFIG_PATH is not properly set, or if the Python install does not have a .pc file
  2. system: uses variables in sysconfig to build the expected library name and searches for that library in recognized compiler search paths (e.g., LD_LIBRARY_PATH on UNIX). This is why I said Meson's a bit stupid because it's already using sysconfig to build library names, but it's not using the sysconfig variables that directly point to the recognized libpython

So, because we build extension modules (i.e., the Cython code), users need one of the following to be true:

  1. pkg-config must be installed
  2. Library search variables (e.g., LD_LIBRARY_PATH) need to be properly set

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelmckinsey1 when you get the chance, can you try at least one of these solutions on Windows? I'll try on macOS. If this works, I'll try to see if there's a way I can add pkg-config to the build dependencies

py_top_install_dir = py.get_install_dir()

# Verify that the version from version.py matches the Meson project version
version_run = run_command(py.path(), meson.current_source_dir() / 'hatchet' / 'util' / 'print_version.py')
if version_run.returncode() != 0
error('The __version__ variable in Hatchet cannot be determined')
endif
version_from_py = version_run.stdout().strip()
if not version_from_py.version_compare(meson.project_version())
error('The __version__ variable in Hatchet does not match the Meson project version')
endif

# Enter the 'hatchet' subdirectory
subdir('hatchet')
70 changes: 51 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,65 @@
[build-system]
requires = ["setuptools", "wheel", "Cython"]
build-backend = "setuptools.build_meta"
requires = ["meson-python", "meson[ninja]", "Cython"]
build-backend = "mesonpy"

[tool.poetry]
[project]
name = "llnl-hatchet"
version = "2024.1.1"
description = "A Python library for analyzing hierarchical performance data."
description = "A Python library for analyzing hierarchical performance data"
dynamic = ["version"]
readme = "./README.md"
license = { file="LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
]
authors = [
"Abhinav Bhatele <bhatele@cs.umd.edu>",
"Stephanie Brink <brink2@llnl.gov>",
"Todd Gamblin <tgamblin@llnl.gov>",
{ name = "Abhinav Bhatele", email = "bhatele@cs.umd.edu" },
{ name = "Stephanie Brink", email = "brink2@llnl.gov" },
{ name = "Todd Gamblin", email = "tgamblin@llnl.gov" }
]
maintainers = [
{ name = "Olga Pearce", email = "pearce8@llnl.gov" },
{ name = "Ian Lumsden", email = "ilumsden@vols.utk.edu" },
{ name = "Connor Scully-Allison", email = "cscullyallison@sci.utah.edu" },
{ name = "Dewi Yokelson", email = "dewiy@cs.uoregon.edu" },
{ name = "Michael McKinsey", email = "michaelmckinsey@tamu.edu" }
]
requires-python = ">= 3.7"
dependencies = [
"pydot",
"PyYAML",
"matplotlib",
"numpy",
"pandas",
"textX >= 3.0.0",
"multiprocess",
"caliper-reader",
]

[project.urls]
source_code = "https://github.com/llnl/hatchet"
documentation = "https://llnl-hatchet.readthedocs.io/en/latest/"

[project.optional-dependencies]
hdf_writer = [
"tables"
]
license = "MIT"

[tool.ruff]
line-length = 88
target-version = 'py37'
include = ['\.pyi?$']
exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".tox",
".venv",
"_build",
"buck-out",
"build",
"dist",
".eggs",
".git",
".hg",
".mypy_cache",
".tox",
".venv",
"_build",
"buck-out",
"build",
"dist",
]

[tool.black]
Expand Down
Loading