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
11 changes: 11 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: ChangelogUpdated

on:
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- develop

jobs:
call-workflow:
uses: lsst-ts/tssw_workflows/.github/workflows/news_creation.yaml@main
14 changes: 9 additions & 5 deletions .ts_pre_commit_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
check-yaml: true
black: false
check-xml: true
black: true
flake8: true
isort: true
mypy: false
check-yaml: true
clang-format: false
flake8: false
format-xmllint: false
isort: false
mypy: true
nbstripout: false
ruff: true
towncrier: true
4 changes: 1 addition & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
This configuration only affects single-package Sphinx documentation builds.
"""

import lsst.ts.scriptqueue # noqa
from documenteer.conf.pipelinespkg import * # type: ignore # noqa
from documenteer.conf.guide import * # type: ignore # noqa

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

intersphinx_mapping["ts_salobj"] = ("https://ts-salobj.lsst.io", None) # type: ignore # noqa
intersphinx_mapping["ts_utils"] = ("https://ts-utils.lsst.io", None) # type: ignore # noqa
Expand Down
15 changes: 15 additions & 0 deletions doc/documenteer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

[project]
title = "ScriptQueue CSC."
copyright = "2015-2024 Association of Universities for Research in Astronomy, Inc. (AURA)"
github_url = "https://github.com/lsst-ts/ts_scriptqueue"

[project.python]
package = "ts_scriptqueue"
documentation_url_key = "documentation"
github_url_key = "repository"

[sphinx.intersphinx.projects]
ts_xml = "https://ts-xml.lsst.io"
ts_salobj = "https://ts-salobj.lsst.io"
python = "https://docs.python.org/3.13/"
1 change: 1 addition & 0 deletions doc/news/OSW-350.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update documentation build.
1 change: 1 addition & 0 deletions doc/news/OSW-350.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added estimated start time to the next visit event in script_queue.py.
1 change: 1 addition & 0 deletions doc/news/OSW-350.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for type checking with mypy.
42 changes: 42 additions & 0 deletions doc/news/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Recording Changes
=================

This directory contains "news fragments" which are small, structured text files that contain information about changes or updates that will be included in the release notes.
These fragments are used to automatically generate changelogs or release notes.
They can be written restructured text format or plain text.

Each file should be named like ``<JIRA TICKET>.<TYPE>.<EXT>`` with a file extension defining the markup format (``rst|md``).
The ``<TYPE>`` should be one of:

* ``feature``: A new feature
* ``bugfix``: A bug fix.
* ``perf``: A performance enhancement.
* ``doc``: A documentation improvement.
* ``removal``: A deprecation or removal of API.
* ``misc``: Other minor changes and/or additions

An example file name would therefore look like ``DM-40534.doc.rst``.

Each developer now has to create the news fragments for the changes they have made on their own branches,
instead of adding them to the release notes directly.
The news fragments are then automatically integrated into the release notes by the ``towncrier`` tool.

You can test how the content will be integrated into the release notes by running ``towncrier build --draft --version=v<X.XX.X>``.
Note that you have to run it from the root repository directory (i.e. the ``ts_scriptqueue``).

In order to update the release notes file for real, the person responsible for the releasing the notes should run:

.. code-block:: bash

$ towncrier build --version=v<X.XX.X>


.. note::

When running towncrier to build the changelog, you may be prompted to confirm the deletion of fragments.
If you would like to retain the fragments in the doc/news directory do not confirm the deletion.

Note also that ``towncrier`` can be installed from PyPI or conda-forge.



3 changes: 3 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
documenteer[pipelines,guide]
sphinxext-rediraffe

2 changes: 2 additions & 0 deletions doc/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Version History
###############

.. towncrier release notes start

v2.14.2
-------

Expand Down
25 changes: 14 additions & 11 deletions python/lsst/ts/scriptqueue/block_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

__all__ = ["BlockInfo"]

import logging
import os
import re
from collections import deque

from lsst.ts.utils import ImageNameServiceClient

from .type_hints import ScriptInfoProtocol

BLOCK_REGEX = re.compile(r"(?P<block_test_case>BLOCK-T)?(?P<block>BLOCK-)?(?P<id>[0-9]*)")


Expand All @@ -47,20 +50,20 @@ class BlockInfo:
How many scripts are part of this block.
"""

def __init__(self, log, block_id, block_size):
def __init__(self, log: logging.Logger, block_id: str, block_size: int) -> None:
self.log = log.getChild("BlockInfo")
self.block_id = block_id
self.block_size = block_size

block_match = BLOCK_REGEX.match(block_id)
if block_match.span()[1] == 0:
if block_match is None or block_match.span()[1] == 0:
raise ValueError(f"{block_id} has the wrong format, should be BLOCK-N or BLOCK-TN.")

self._block_ticket_id = abs(int(block_match.groupdict()["id"]))
self._block_type = "BlockT" if block_match.groupdict()["block_test_case"] is not None else "Block"

self._block_uid = None
self.scripts_info = deque(maxlen=block_size)
self._block_uid: str | None = None
self.scripts_info: deque[ScriptInfoProtocol] = deque(maxlen=int(block_size))

self.image_server_url = os.environ.get("IMAGE_SERVER_URL")
if self.image_server_url is None:
Expand All @@ -69,20 +72,20 @@ def __init__(self, log, block_id, block_size):
"Block indexing functionality will not work."
)

def get_block_uid(self):
def get_block_uid(self) -> str:
"""Retrieve block uid.

Returns
-------
block_uid : `str`
Block unique id.
"""
if not self.has_uid():
if self._block_uid is None:
raise RuntimeError("Block uid has not been set yet, call set_block_uid first.")

return self._block_uid

def has_uid(self):
def has_uid(self) -> bool:
"""Check if block uid was set.

Returns
Expand All @@ -92,7 +95,7 @@ def has_uid(self):
"""
return self._block_uid is not None

async def set_block_uid(self):
async def set_block_uid(self) -> None:
"""Retrieve and set the block unique id from the name server."""

if self._block_uid is not None:
Expand All @@ -105,12 +108,12 @@ async def set_block_uid(self):
_, data = await image_server_client.get_next_obs_id(num_images=1)
self._block_uid = data[0]

def add(self, script_info):
def add(self, script_info: ScriptInfoProtocol) -> None:
"""Add Script to the block.

Parameters
----------
script_info : `ScriptInfo`
script_info : `ScriptInfoProtocol`
ScriptInfo for the script to add to the block.
"""
if self._block_uid is None:
Expand All @@ -127,7 +130,7 @@ def add(self, script_info):
self.scripts_info.append(script_info)
script_info.set_block_index(index)

def done(self):
def done(self) -> bool:
"""Check if block is done.

A block is considered done is all the scripts that
Expand Down
14 changes: 8 additions & 6 deletions python/lsst/ts/scriptqueue/block_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"BlockModel",
]

from .block_info import BlockInfo


class BlockModel:
"""Manages block information.
Expand All @@ -34,11 +36,11 @@ class BlockModel:
fails the entire block must fail.
"""

def __init__(self):
self.blocks = dict()
self.current_blocks = dict()
def __init__(self) -> None:
self.blocks: dict[str, dict[str, BlockInfo]] = dict()
self.current_blocks: dict[str, str] = dict()

def add_block(self, block_info):
def add_block(self, block_info: BlockInfo) -> None:
"""Add block info to the list of blocks.

When a new block is added it will become the "current"
Expand All @@ -60,7 +62,7 @@ def add_block(self, block_info):

self.current_blocks[block_info.block_id] = block_info.get_block_uid()

def get_current_block(self, block_id):
def get_current_block(self, block_id: str) -> BlockInfo:
"""Return the BlockInfo for the current block.

Parameters
Expand All @@ -81,7 +83,7 @@ def get_current_block(self, block_id):

return block_info

def remove_done_blocks(self):
def remove_done_blocks(self) -> None:
"""Remove blocks that have already finished."""

for block in self.blocks:
Expand Down
Loading