Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The workflow is named "Test" but only verifies that the package can be imported successfully. It doesn't run any actual test suite. Consider renaming this workflow to something more accurate like "Install and Verify" or "Build" to avoid confusion, or add actual test execution if test files exist or are planned.

Suggested change
name: Test
name: Install and Verify

Copilot uses AI. Check for mistakes.

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --frozen
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The workflow installs Python with uv python install but doesn't explicitly configure uv to use that specific Python version for subsequent commands. Consider pinning the Python version by either: (1) using uv sync --python ${{ matrix.python-version }}, or (2) setting up the Python version using GitHub's actions/setup-python action before installing uv, which will ensure uv automatically detects and uses that Python version.

Suggested change
run: uv sync --frozen
run: uv sync --frozen --python ${{ matrix.python-version }}

Copilot uses AI. Check for mistakes.

- name: Verify installation
run: uv run python -c "import math_spec_mapping; print(math_spec_mapping.__version__)"
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The verification step attempts to print math_spec_mapping.__version__, but the __init__.py file does not define a __version__ attribute. This will cause the workflow to fail. Either add a __version__ attribute to the package's __init__.py file, or change this verification to a simpler import check without accessing the version attribute.

Suggested change
run: uv run python -c "import math_spec_mapping; print(math_spec_mapping.__version__)"
run: uv run python -c "import math_spec_mapping"

Copilot uses AI. Check for mistakes.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ One good example is the [wiring report](https://github.com/BlockScience/Predator

To install the library, simply pip install by running "pip install math-spec-mapping". The pypi package can be found [here](https://pypi.org/project/math-spec-mapping/).

For development setup instructions, including using [uv](https://docs.astral.sh/uv/) for faster, reproducible dependency management, see [SETUP.md](SETUP.md).

## Why MSML?

Writing mathematical specifications can be a difficult process, especially when variable names are changed or new mechanisms are introduced. MSML seeks to streamline the process with automations as well as enhance the abilities of static math specs to deliver deeper insights. Because it is automated, one can write specifications at different levels of details or for different purposes.
Expand Down
100 changes: 100 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Development Setup

## Prerequisites

- Python 3.8 or higher
- [uv](https://docs.astral.sh/uv/) - Fast Python package installer and resolver

## Installing uv

If you don't have uv installed, install it using one of these methods:

```bash
# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

# Using pip
pip install uv
```

## Setting Up the Development Environment

1. Clone the repository:
```bash
git clone https://github.com/BlockScience/MSML.git
cd MSML
```

2. Install dependencies using uv:
```bash
uv sync
```

This will:
- Create a virtual environment in `.venv/`
- Install all project dependencies
- Install the package in editable mode

3. Activate the virtual environment:
```bash
# On macOS/Linux
source .venv/bin/activate

# On Windows
.venv\Scripts\activate
```

## Running Commands in the Virtual Environment

You can run commands in the virtual environment without activating it:

```bash
# Run Python scripts
uv run python your_script.py

# Run installed command-line tools
uv run <command>
```

## Installing the Library for Users

For regular users who just want to use MSML (not develop it):

```bash
pip install math-spec-mapping
```

Or with uv:

```bash
uv pip install math-spec-mapping
```

## Adding New Dependencies

If you need to add a new dependency to the project:

```bash
# Add a dependency
uv add <package-name>

# Add a development dependency
uv add --dev <package-name>
Comment on lines +84 to +85
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The flag --dev for adding development dependencies may not be the correct syntax for uv. As of recent uv versions, development dependencies are typically added using --group dev or by specifying them in [project.optional-dependencies] or [tool.uv.dev-dependencies] sections in pyproject.toml. Please verify the correct syntax for the version of uv being used.

Suggested change
# Add a development dependency
uv add --dev <package-name>
# Add a development dependency (in the "dev" group)
uv add --group dev <package-name>

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot can you help solve

The failure is due to this line in src/math_spec_mapping/Load/type.py (ref: 187b270):

from typing import _UnionGenericAlias, List, _GenericAlias

The names _UnionGenericAlias and _GenericAlias are private members of the typing module and are not guaranteed to exist in all Python versions. In Python 3.8, these members areThe job failed due to ImportError: cannot import name '_UnionGenericAlias' from 'typing'. This occurs because _UnionGenericAlias and _GenericAlias are internal classes and are not part of the public API of the typing module. They are not guaranteed to exist across Python versions and their use is discouraged outside the standard library.

To fix this, replace any references to _UnionGenericAlias and _GenericAlias with public interfaces. For checking generic types like Union or List, you can use typing.get_origin and typing.get_args (available in Python 3.8+).

Update the relevant section in src/math_spec_mapping/Load/type.py (ref: 187b270) as follows:

from typing import List, get_origin

# Remove: from typing import _UnionGenericAlias, List, _GenericAlias

# In your logic where _UnionGenericAlias or _GenericAlias not directly importable, causing the ImportError.

To fix this:

1. Remove the import of _UnionGenericAlias and _GenericAlias from the import statement.
2. Use typing's public API to check for union and generic aliases. In Python 3.8+, the best practice is to use typing.get_origin and typing.get_args (Python 3.8+ with typing_extensions, otherwise Python 3.9+ natively).

Here's how you could change the logic:

```python
from are used:
if get_origin(data["type"]["python"]) is not None:
    data["type_name"]["python"] = data["type"]["python"].__repr__()
else:
    data["type_name"]["python"] = data["type"]["python"].__name__

This change uses get_origin to check for generic types instead of relying on internal classes. This will resolve the ImportError and make the code forward-compatible with modern Python versions.

```

Then commit the updated `pyproject.toml` and `uv.lock` files.

## Updating Dependencies

To update all dependencies to their latest compatible versions:

```bash
uv sync --upgrade
```

## CI/CD Integration

The project uses uv in CI workflows for fast, reproducible builds. See `.github/workflows/` for examples.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
"pypandoc>=1.15",
]
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
Loading
Loading