Skip to content
Closed
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
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --group dev

- name: Run tests
run: uv run pytest

ruff:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v4

- uses: benny123tw/action-ruff@v1.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
filter_mode: diff_context
170 changes: 170 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
.python-version

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# VSCode
.vscode/

# Custom
tmpdev/

# setuptools-scm generated version file
src/sosci/__about__.py
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.12.5
hooks:
- id: ruff

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-toml
- id: check-merge-conflict
- id: debug-statements

# Replace commitsar with conventional commit checker
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [] # default: [feat, fix, ci, chore, docs, style, refactor, perf, test, build, revert]
Empty file added README.md
Empty file.
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[project]
name = "sosci"
dynamic = ["version"]
description = "A package with all the important SO software and computing infrastructure."
readme = "README.md"
authors = [
{ name = "Ioannis Paraskevakos", email = "iparask@princeton.edu" }
]
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"sotodlib>=0.6.16",
"globus_sdk>=4.0"
]

[project.scripts]
sosci = "sosci.__main__:main"

[build-system]
requires = ["setuptools>=61", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
sosci = ["*.txt"]

[tool.isort]
line_length = 120
profile = "black"
skip = ["docs", ".github", ".vscode", "container", "env", "env311", "build", "src/sosci/__about__.py"]

[tool.setuptools_scm]
version_file = "src/sosci/__about__.py"

[dependency-groups]
dev = [
"black>=26.1.0",
"isort>=7.0.0",
"pytest>=9.0.2",
"ruff>=0.15.0",
"coverage",
"pytest-cov>=2.6",
"coveralls>=1.5",
"pre-commit",
]

[tool.coverage.run]
source_pkgs = ["sosci", "tests"]
branch = true
parallel = true
omit = ["src/sosci/__about__.py"]

[tool.coverage.paths]
sosci = ["src/sosci", "*/sosci/src/sosci"]
tests = ["tests", "*/sosci/tests"]

[tool.coverage.report]
exclude_lines = ["pragma: no cover"]
exclude_also = ["if TYPE_CHECKING:"]
omit = ["*/sosci/src/sosci/__main__.py"]

[tool.ruff]
line-length = 120
exclude = ["docs", ".github", ".vscode", "container", "env", "env311", "build", "src/sosci/__about__.py"]
Empty file added src/sosci/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions src/sosci/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from argparse import ArgumentParser, Namespace
from logging import basicConfig, getLogger

from sosci.cli import SUBCOMMANDS


def get_parser() -> ArgumentParser:
"""Create and return the argument parser for the SO campaign."""
parser = ArgumentParser(description="Run the SO campaign.")
# Make sure all args here are redirected to vars starting with
# '_'. We are going to clean those off before passing to the
# subcommand.
sps = parser.add_subparsers(dest='_pipemod', required=True)

for name, module in SUBCOMMANDS.items():
sp = sps.add_parser(name)
module.get_parser(sp)

return parser


def main() -> None:

logger = getLogger(name="sosci")
basicConfig(filename='sosci.log', level="DEBUG")
parser = get_parser()
args = parser.parse_args()

# Extract top-level args ...
top_args = {k: v for k, v in vars(args).items()
if k[0] == '_'}
for k in top_args:
delattr(args, k)
top_args = Namespace(**top_args)

module = SUBCOMMANDS[top_args._pipemod]
_main = getattr(module, '_main', None)
if _main is not None:
_main(args, logger=logger)
4 changes: 4 additions & 0 deletions src/sosci/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import metadata # noqa: F401
from . import purge # noqa: F401

SUBCOMMANDS = {"metadata-sync": metadata, "metadata-purge": purge}
Loading
Loading