Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/test_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
tags: ["v*"]

env:
PKG_NAME: commons
MODULE_NAME: commons
PKG_NAME: neutrons_standard
MODULE_NAME: neutrons_standard

# cancel previous job if new commit is pushed
concurrency:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ channels = [
]

[tool.pixi.dependencies]
commons = "*"
neutrons_standard = "*"

[tool.pixi.package.run-dependencies]
commons = "*"
neutrons_standard = "*"
```

Then import utilities:

```python
from commons import Config
from commons.decorators.singleton import Singleton
from commons.time import timestamp, isoFromTimestamp
from neutrons_standard import Config
from neutrons_standard.decorators.singleton import Singleton
from neutrons_standard.time import timestamp, isoFromTimestamp
```

See [`readthedocs`](https://pythoncommons.readthedocs.io/en/latest/) for detailed documentation on each module.
Expand Down Expand Up @@ -114,7 +114,7 @@ Output will be in `docs/_build/html/`.

```
PythonCommons/
├── src/commons/ # Main package
├── src/neutrons_standard/ # Main package
│ ├── config.py # Configuration management
│ ├── time.py # Time utilities
│ └── decorators/
Expand Down
4 changes: 2 additions & 2 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Quick Reference

.. code-block:: python

from commons import Config
from neutrons_standard import Config

# Access values
Config["database.host"] # Dot-delimited lookup
Expand Down Expand Up @@ -169,7 +169,7 @@ Basic Usage

.. code-block:: python

from commons import Config
from neutrons_standard import Config

# Read values
host = Config["database.host"]
Expand Down
8 changes: 4 additions & 4 deletions docs/singleton.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Quick Reference

.. code-block:: python
from commons.decorators.singleton import Singleton, reset_Singletons
from neutrons_standard.decorators.singleton import Singleton, reset_Singletons
@Singleton
class MyService:
Expand Down Expand Up @@ -96,7 +96,7 @@ Reset all singletons:

.. code-block:: python
from commons.decorators.singleton import reset_Singletons
from neutrons_standard.decorators.singleton import reset_Singletons
reset_Singletons() # Reset all
reset_Singletons(fully_unwrap=True) # Fully unwrap all
Expand All @@ -110,7 +110,7 @@ Pytest Fixture
.. code-block:: python
import pytest
from commons.decorators.singleton import reset_Singletons
from neutrons_standard.decorators.singleton import reset_Singletons
@pytest.fixture(autouse=True)
def reset_all_singletons():
Expand Down Expand Up @@ -201,7 +201,7 @@ Configuration Objects

.. code-block:: python
from commons import Config # Already a Singleton
from neutrons_standard import Config # Already a Singleton
# Config is single instance across app
cfg = Config
Expand Down
18 changes: 9 additions & 9 deletions docs/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Quick Reference

.. code-block:: python

from commons.time import timestamp, parseTimestamp, isoFromTimestamp
from neutrons_standard.time import timestamp, parseTimestamp, isoFromTimestamp

# Generate timestamps
ts = timestamp() # Current time (float seconds)
Expand Down Expand Up @@ -86,7 +86,7 @@ Event Logging

.. code-block:: python

from commons.time import timestamp, isoFromTimestamp
from neutrons_standard.time import timestamp, isoFromTimestamp

events = []
for event_type in ["login", "query", "logout"]:
Expand All @@ -101,7 +101,7 @@ Performance Measurement

.. code-block:: python

from commons.time import timestamp
from neutrons_standard.time import timestamp

start = timestamp()
perform_operation()
Expand All @@ -113,7 +113,7 @@ Timestamp Conversion Round-Trip

.. code-block:: python

from commons.time import timestamp, isoFromTimestamp, parseTimestamp
from neutrons_standard.time import timestamp, isoFromTimestamp, parseTimestamp

# Original timestamp
ts1 = timestamp()
Expand All @@ -130,7 +130,7 @@ Configuration Backup Timestamping

.. code-block:: python

from commons.time import isoFromTimestamp, timestamp
from neutrons_standard.time import isoFromTimestamp, timestamp
from pathlib import Path

def backup_file(filepath):
Expand All @@ -147,7 +147,7 @@ Audit Trails

.. code-block:: python

from commons.time import timestamp, isoFromTimestamp
from neutrons_standard.time import timestamp, isoFromTimestamp

class AuditLog:
def __init__(self):
Expand All @@ -169,7 +169,7 @@ Time Series Data

.. code-block:: python

from commons.time import timestamp, isoFromTimestamp
from neutrons_standard.time import timestamp, isoFromTimestamp

class TimeSeries:
def __init__(self):
Expand All @@ -193,7 +193,7 @@ Database Integration

.. code-block:: python

from commons.time import timestamp, isoFromTimestamp, parseTimestamp
from neutrons_standard.time import timestamp, isoFromTimestamp, parseTimestamp

class DatabaseRecord:
def __init__(self, data):
Expand Down Expand Up @@ -234,7 +234,7 @@ With ``ensureUnique=True``, timestamps strictly increase even in same second:

.. code-block:: python

from commons.time import timestamp
from neutrons_standard.time import timestamp

times = [timestamp(ensureUnique=True) for _ in range(100)]

Expand Down
40 changes: 20 additions & 20 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
### Project Metadata ###
########################
[project]
name = "commons"
name = "neutrons_standard"
description = "Python library repo for atomic software components generally applicable across neutrons repositories."
dynamic = ["version"]
requires-python = ">=3.10"
Expand Down Expand Up @@ -36,19 +36,19 @@ requires = ["hatchling", "versioningit"]
source = "versioningit"

[tool.hatch.build.hooks.versioningit-onbuild]
source-file = "src/commons/_version.py"
build-file = "commons/_version.py"
source-file = "src/neutrons_standard/_version.py"
build-file = "neutrons_standard/_version.py"

[tool.hatch.build]
artifacts = [
"src/commons/_version.py",
"src/commons/**/*.yml",
"src/commons/**/*.yaml",
"src/commons/**/*.ini",
"src/neutrons_standard/_version.py",
"src/neutrons_standard/**/*.yml",
"src/neutrons_standard/**/*.yaml",
"src/neutrons_standard/**/*.ini",
]

[tool.hatch.build.targets.wheel]
packages = ["src/commons"]
packages = ["src/neutrons_standard"]

[tool.versioningit.vcs]
method = "git"
Expand All @@ -67,7 +67,7 @@ dirty = "{version}"
distance-dirty = "{next_version}.dev{distance}"

[tool.versioningit.write]
file = "src/commons/_version.py"
file = "src/neutrons_standard/_version.py"

###################
### Pixi config ###
Expand Down Expand Up @@ -101,7 +101,7 @@ pillow = ">=12.1.1" # CVE-2026-25990

[tool.pixi.pypi-dependencies]
# PyPI dependencies, including this package to allow local editable installs
commons = { path = ".", editable = true }
neutrons_standard = { path = ".", editable = true }
jaraco-context = ">=6.1.0" # CVE-2026-23949

# Pixi Build configuration - https://pixi.sh/latest/reference/pixi_manifest/#pixi-build
Expand All @@ -116,7 +116,7 @@ numpy = "*"
"ruamel.yaml" = "*"

[tool.pixi.package]
name = "commons"
name = "neutrons_standard"
version = "0.0.0" # placeholder, overwritten by sync-version

[tool.pixi.package.build]
Expand Down Expand Up @@ -211,7 +211,7 @@ reset-toml = { cmd = "cp pyproject.toml.bak pyproject.toml; rm pyproject.toml.ba
##############

[tool.pytest.ini_options]
addopts = "-v --cov=commons --cov-report=term-missing"
addopts = "-v --cov=neutrons_standard --cov-report=term-missing"
pythonpath = [".", "src", "scripts"]
testpaths = ["tests"]
python_files = ["test*.py"]
Expand Down Expand Up @@ -239,7 +239,7 @@ select = ["A", "ARG", "ASYNC", "BLE", "C90", "E", "F", "I", "N", "UP032", "W"]
ignore = []

[tool.ruff.lint.isort]
known-first-party = ["commons"]
known-first-party = ["neutrons_standard"]

[tool.ruff.format]
quote-style = "double"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Contains the entry point for the application"""

from commons.decorators.singleton import Singleton
from neutrons_standard.decorators.singleton import Singleton


try:
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions src/neutrons_standard/help/help_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""single help module"""

import webbrowser

from neutrons_standard.configuration import get_data


def help_function(context):
"""Open a browser with the appropriate help page"""
help_url = get_data("global.other", "help_url")
if context:
webbrowser.open(help_url)
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os
import pytest

import commons
from commons.decorators.singleton import reset_Singletons
import neutrons_standard
from neutrons_standard.decorators.singleton import reset_Singletons

commons.init("commons")
neutrons_standard.init("neutrons_standard")

if not os.environ.get("env"):
os.environ["env"] = "test"
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ templated:

user:
application:
home: ~/.commons/
home: ~/.neutrons_standard/

test:
multi-substitution:
Expand Down
Loading