Skip to content

Commit

Permalink
Merge pull request #70 from lsst-ts/tickets/DM-40054
Browse files Browse the repository at this point in the history
Update MTAOS to remove usage of flake8 and black pytest plugins.
  • Loading branch information
tribeiro authored Aug 9, 2023
2 parents 021750b + 027c526 commit 37e6037
Show file tree
Hide file tree
Showing 27 changed files with 213 additions and 157 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ChangelogUpdated
on:
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- develop
jobs:
build:
name: Check Actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Changelog check
uses: Zomzog/[email protected]
with:
fileName: doc/versionHistory.rst
checkNotification: Simple
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: lint

on:
- push
- pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install
run: |
$CONDA/bin/conda install -c lsstts ts-pre-commit-config -y
$CONDA/bin/conda install -c conda-forge pre-commit -y
$CONDA/bin/generate_pre_commit_conf
- name: Run pre commit checks
run: $CONDA/bin/pre-commit run --all
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ pytest_session.txt

# Mac related files
.DS_Store
.hypothesis/
.hypothesis/
.pre-commit-config.yaml
.flake8
.isort.cfg
.mypy.ini
6 changes: 6 additions & 0 deletions .ts_pre_commit_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
check-yaml: true
check-xml: true
black: true
flake8: true
isort: true
mypy: false
33 changes: 13 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ pipeline {
dir(env.WORKSPACE + '/ts_mtaos') {
checkout scm
}
dir(env.WORKSPACE + '/phosim_utils') {
git branch: 'main', url: 'https://github.com/lsst-dm/phosim_utils.git'
}
dir(env.WORKSPACE + '/ts_wep') {
git branch: "${BRANCH}", url: 'https://github.com/lsst-ts/ts_wep.git'
}
Expand All @@ -78,11 +75,7 @@ pipeline {
cd ${env.SAL_USERS_HOME} && { curl -O ${env.PLANTUML_URL} ; cd -; }
pip install sphinxcontrib-plantuml
cd phosim_utils/
setup -k -r . -t ${env.STACK_VERSION}
scons
cd ../ts_wep/
cd ${env.WHOME}/ts_wep/
setup -k -r .
scons python
Expand Down Expand Up @@ -112,16 +105,19 @@ pipeline {
set +x
source ${env.SAL_SETUP_FILE}
cd phosim_utils/
setup -k -r . -t ${env.STACK_VERSION}
cd ../ts_wep/
cd ${env.WHOME}/ts_wep/
setup -k -r .
cd ../ts_ofc/
echo Checkout wep lfs data
git lfs install || echo git lfs install FAILED
git lfs fetch --all || echo git lfs fetch FAILED
git lfs checkout || echo git lfs checkout FAILED
cd ${env.WHOME}/ts_ofc/
setup -k -r .
cd ../ts_mtaos/
cd ${env.WHOME}/ts_mtaos/
setup -k -r .
# Exclude integration tests from the initial run.
Expand All @@ -142,16 +138,13 @@ pipeline {
set +x
source ${env.SAL_SETUP_FILE}
cd phosim_utils/
setup -k -r . -t ${env.STACK_VERSION}
cd ../ts_wep/
cd ${env.WHOME}/ts_wep/
setup -k -r .
cd ../ts_ofc/
cd ${env.WHOME}/ts_ofc/
setup -k -r .
cd ../ts_mtaos/
cd ${env.WHOME}/ts_mtaos/
setup -k -r .
package-docs build
Expand Down
4 changes: 0 additions & 4 deletions SConstruct

This file was deleted.

4 changes: 3 additions & 1 deletion bin/mtaos
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class MTAOSCommander(salobj.CscCommander):
self.mtaos_remote = salobj.Remote(
domain=self.remote.salinfo.domain, name="MTAOS"
)
self.mtaos_remote.evt_settingsApplied = functools.partial(self.settings_callback)
self.mtaos_remote.evt_settingsApplied = functools.partial(
self.settings_callback
)

self.mtaos_remote.tel_wepDuration.callback = functools.partial(
self.duration_callback, name="wepDuration"
Expand Down
12 changes: 6 additions & 6 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
This configuration only affects single-package Sphinx documentation builds.
"""

from documenteer.conf.pipelinespkg import *
import lsst.ts.mtaos
import lsst.ts.mtaos # noqa
from documenteer.conf.pipelinespkg import * # noqa

project = "ts_mtaos"
html_theme_options["logotext"] = project
html_theme_options["logotext"] = project # noqa
html_title = project
html_short_title = project
doxylink = {} # Avoid warning: Could not find tag file _doxygen/doxygen.tag

intersphinx_mapping["ts_xml"] = ("https://ts-xml.lsst.io", None)
intersphinx_mapping["ts_salobj"] = ("https://ts-salobj.lsst.io", None)
intersphinx_mapping["ts_xml"] = ("https://ts-xml.lsst.io", None) # noqa
intersphinx_mapping["ts_salobj"] = ("https://ts-salobj.lsst.io", None) # noqa

# Support the sphinx extension of plantuml
extensions.append("sphinxcontrib.plantuml")
extensions.append("sphinxcontrib.plantuml") # noqa

# Put the path to plantuml.jar
plantuml = "java -jar /home/saluser/plantuml.jar"
8 changes: 8 additions & 0 deletions doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Version History
===============

v0.12.1
-------

* Add support for ts-pre-commit-config.
* Update package setup files.
* Add git workflows to check version history is updated and linting.
* Run isort.

v0.12.0
-------

Expand Down
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = [ "setuptools", "setuptools_scm" ]
build-backend = "setuptools.build_meta"

[project]
name = "ts_mtaos"
description = "Main Telescope Active Optical System."
license = { text = "GPL" }
classifiers = [ "Programming Language :: Python :: 3" ]
urls = { documentation = "https://ts-mtaos.lsst.io", repository = "https://github.com/lsst-ts/ts_mtaos" }
dynamic = [ "version" ]

[tool.setuptools.dynamic]
version = { attr = "setuptools_scm.get_version" }

[tool.setuptools.packages.find]
where = [ "python" ]

[project.scripts]
run_mtaos = "lsst.ts.mtaos:run_mtaos"

[tool.setuptools_scm]
write_to = "python/lsst/ts/mtaos/version.py"
write_to_template = """
# Generated by setuptools_scm
__all__ = ["__version__"]
__version__ = "{version}"
"""

[tool.pytest.ini_options]
asyncio_mode = "auto"

[project.optional-dependencies]
dev = ["documenteer[pipelines]"]
4 changes: 2 additions & 2 deletions python/lsst/ts/mtaos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
except ImportError:
__version__ = "?"

from .wavefront_collection import *
from .config import *
from .config_schema import *
from .model import *
from .utility import *
from .mtaos import *
from .utility import *
from .wavefront_collection import *
3 changes: 2 additions & 1 deletion python/lsst/ts/mtaos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

__all__ = ["Config"]

from collections import namedtuple
import warnings
from collections import namedtuple

import yaml

from . import utility
Expand Down
36 changes: 15 additions & 21 deletions python/lsst/ts/mtaos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,35 @@

__all__ = ["Model"]

import os
import copy
import yaml
import shutil
import asyncio
import concurrent.futures
import contextlib
import copy
import functools
import logging
import os
import shutil
import tempfile
import functools
import contextlib
import concurrent.futures

import numpy as np

from typing import Optional

import numpy as np
import yaml
from lsst.afw.image import VisitInfo
from lsst.daf import butler as dafButler
from lsst.ts.ofc import OFC
from lsst.ts.utils import make_done_future
from lsst.ts.salobj import DefaultingValidator

from lsst.afw.image import VisitInfo
from lsst.ts.utils import make_done_future
from lsst.ts.wep.utility import writePipetaskCmd

from .config_schema import (
CWFS_PIPELINE_CONFIG,
WEP_HEADER_CONFIG,
ISR_CONFIG,
GENERATE_DONUT_CATALOG_CONFIG,
ISR_CONFIG,
SCIENCE_SENSOR_PIPELINE_CONFIG,
WEP_HEADER_CONFIG,
)

from .utility import define_visit, get_formatted_corner_wavefront_sensors_ids, timeit
from .wavefront_collection import WavefrontCollection
from .utility import define_visit, timeit, get_formatted_corner_wavefront_sensors_ids

from lsst.ts.wep.utility import writePipetaskCmd

from lsst.daf import butler as dafButler


class Model:
Expand Down
18 changes: 6 additions & 12 deletions python/lsst/ts/mtaos/mtaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,22 @@

__all__ = ["MTAOS"]

import eups
import yaml
import typing
import inspect
import asyncio
import inspect
import logging
import typing
import warnings

from astropy import units as u

import eups
import numpy as np

import yaml
from astropy import units as u
from lsst.ts import salobj
from lsst.ts.idl.enums.MTAOS import FilterType
from lsst.ts.ofc import OFCData
from lsst.ts.utils import astropy_time_from_tai_unix

from . import CONFIG_SCHEMA, TELESCOPE_DOF_SCHEMA
from . import Config
from . import Model
from . import utility
from . import __version__
from . import CONFIG_SCHEMA, TELESCOPE_DOF_SCHEMA, Config, Model, __version__, utility

try:
from lsst.ts.ofc import __version__ as __ofc_version__
Expand Down
12 changes: 5 additions & 7 deletions python/lsst/ts/mtaos/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@
"define_visit",
]

import asyncio
import logging
import os
import re
import time
import typing
import asyncio
import logging

from logging.handlers import RotatingFileHandler
from enum import Enum, auto
from logging.handlers import RotatingFileHandler
from pathlib import Path

from lsst.utils import getPackageDir
from lsst.daf.butler import Butler
from lsst.obs.base import DefineVisitsTask, Instrument
from lsst.obs.lsst.translators.lsstCam import LsstCamTranslator

from lsst.ts.salobj import parse_idl
from lsst.ts.idl import get_idl_dir
from lsst.ts.salobj import parse_idl
from lsst.ts.wep.utility import CamType
from lsst.utils import getPackageDir


class WEPWarning(Enum):
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ts/mtaos/wavefront_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

__all__ = ["WavefrontCollection"]

import numpy as np
from collections import deque

import numpy as np


class WavefrontCollection(object):
def __init__(self, maxLeng):
Expand Down
Loading

0 comments on commit 37e6037

Please sign in to comment.