Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b4f2963
Removed walrus operators
Christopher-K-Long Mar 22, 2025
63c36d6
Simplified imports
Christopher-K-Long Mar 22, 2025
88e0c28
Removed unsupported typing
Christopher-K-Long Mar 22, 2025
a8258a2
Added version specific imports
Christopher-K-Long Mar 22, 2025
bd62bd1
Reduced the version requirement to 3.7
Christopher-K-Long Mar 22, 2025
2cba8a3
Updated titles in documentation
Christopher-K-Long Mar 22, 2025
47fcc9d
Added requirements to the README
Christopher-K-Long Mar 22, 2025
439bdee
Test package GitHub workflow now tests on python 3.7 through to 3.13 …
Christopher-K-Long Mar 22, 2025
9e69009
Update test-python-package.yml to use 3.7.1 as 3.7.0 is not supported…
Christopher-K-Long Mar 22, 2025
497c516
Changed version of Ubuntu for GitHub Tests as python 3.7 has not been…
Christopher-K-Long Mar 22, 2025
680609c
Corrected version specific imports
Christopher-K-Long Mar 22, 2025
de135ef
Merge branch 'python3.7_support' of https://github.com/Christopher-K-…
Christopher-K-Long Mar 22, 2025
7ca2ce6
Moved package building to latest python version
Christopher-K-Long Mar 22, 2025
7e3b674
Updated .whl glob
Christopher-K-Long Mar 22, 2025
a7e6830
Bug fix in for loop
Christopher-K-Long Mar 22, 2025
bd961de
bug fix (downloading the builds before installing)
Christopher-K-Long Mar 22, 2025
19dc44a
tyring a different directory pre-fix
Christopher-K-Long Mar 22, 2025
528bda5
picking correct shell
Christopher-K-Long Mar 22, 2025
d7e2d32
without for loop
Christopher-K-Long Mar 22, 2025
99f9d65
printing files
Christopher-K-Long Mar 22, 2025
f22d8c5
bug fix
Christopher-K-Long Mar 22, 2025
83f5e45
returning to for loop strucutre now the dists are actually being down…
Christopher-K-Long Mar 22, 2025
69a97ea
Version 1.1.0
Christopher-K-Long Mar 22, 2025
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
47 changes: 42 additions & 5 deletions .github/workflows/test-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,58 @@ permissions:

jobs:
build:

name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

test:
name: >-
Testing distribution
needs:
- build
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install -e ./
for w in ./dist/*.whl; do python -m pip install $w; done
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
8 changes: 7 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# [saveable-objects](README.md) Change Log

## Release 1.0.0
## Release v1.1.0

This release adds support for earlier python versions that 3.10. Specifically the changes in this release are:
- Support was added for python versions 3.7, 3.8, and 3.9
- Minor updates to the documentation.

## Release v1.0.0

This is the initial release. Future changes to this release will be documented
above.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ The python package can be installed with pip as follows:
pip install saveable-objects
```

### Requirements:

Python >= 3.7

Packages:

- [NumPy](https://numpy.org/)
- [cloudpickle](https://github.com/cloudpipe/cloudpickle)

## Documentation

Documentation including worked examples can be found at: [https://saveable-objects.readthedocs.io/](https://saveable-objects.readthedocs.io/).
Expand All @@ -19,5 +28,5 @@ Source code can be found at: [https://github.com/Christopher-K-Long/saveable-obj

## Version and Changes

The current version is [`1.0.0`](ChangeLog.md#release-100). Please see the [Change Log](ChangeLog.md) for more
The current version is [`1.1.0`](ChangeLog.md#release-110). Please see the [Change Log](ChangeLog.md) for more
details.
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

saveable-objects documentation
==============================
saveable-objects
================

.. include:: ../README.md
:parser: myst_parser.sphinx_
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API Reference
=============================
=============

.. autosummary::
:toctree: _autosummary
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "saveable-objects"
version = "1.0.0"
version = "1.1.0"
authors = [
{ name="Christopher_K._Long", email="ckl45@cam.ac.uk" },
]
Expand All @@ -14,7 +14,7 @@ maintainers = [
description = "A python package for checkpointing, saving, and loading objects."
keywords = ["save", "saving", "saveable", "object", "checkpoint", "checkpointing", "load", "loading"]
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
Expand Down
7 changes: 6 additions & 1 deletion src/saveable_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
A python package for checkpointing, saving, and loading objects.
"""

from ._saveable_object import SaveableObject
import sys

if sys.version_info[1] >= 10: # check if python is version 3.8 or later
from ._saveable_object import SaveableObject
else: # import from the python version 3.7 compatable file
from ._saveable_object_3_7 import SaveableObject
6 changes: 4 additions & 2 deletions src/saveable_objects/_saveable_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def _save(self, path: str, write_mode: Literal["w", "wb", "a", "ab", "x", "xb"]
as `mode` for ``open``. By default ``"wb"``.
"""
if not os.path.exists(path):
if (dirname := os.path.dirname(path)) != '':
dirname = os.path.dirname(path)
if dirname != '':
os.makedirs(dirname, exist_ok=True)
with open(path, write_mode) as file:
cpkl.dump(self, file, pkl.HIGHEST_PROTOCOL)
Expand Down Expand Up @@ -343,7 +344,8 @@ def loadif(cls, *args, **kwargs) -> Tuple["SaveableObject", bool]:
path = bound_args.arguments["path"]
except KeyError:
path = None
if instance := cls.tryload(path):
instance = cls.tryload(path)
if instance:
return instance, True
return cls(*args, **kwargs), False
@classmethod
Expand Down
Loading
Loading