From 4191d3c643b8997e2cafcefd60863c9911090890 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Fri, 5 Jul 2024 15:52:52 +0100 Subject: [PATCH 1/8] Format config in example as a code block --- cats/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cats/__init__.py b/cats/__init__.py index 75eb189..fb2b46c 100644 --- a/cats/__init__.py +++ b/cats/__init__.py @@ -75,13 +75,14 @@ def parse_arguments(): cats -d 90 --loc OX1 -s at -c 'mycommand' To report carbon footprint, pass the `--config` option to select a - configuration file and the `--profile` option to select a profile. An + configuration file and the `--profile` option to select a profile. + The configuration file is documented in the Quickstart section of the online + documentation. An example config file is given below: -{config_text} +.. code-block:: yaml - The configuration file is documented in the Quickstart section of the online - documentation. +{config_text} """ parser = ArgumentParser( @@ -226,7 +227,7 @@ def schedule_at( """ proc = subprocess.Popen(args, stdout=subprocess.PIPE) try: - proc_output = subprocess.check_output( + subprocess.check_output( ( at_command, "-t", From ec9f94da74df33374807cebfd868e184a4ff61c6 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Fri, 5 Jul 2024 15:53:26 +0100 Subject: [PATCH 2/8] docs: fix typo --- docs/source/quickstart.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index ccf552d..a5d97c8 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -76,7 +76,7 @@ quantity of hardware the job using. This information is provided by adding a section ``profiles`` to the :ref:`cats YAML configuration file `. -You can define an arbitraty number of profiles as subsection of the +You can define an arbitrary number of profiles as subsection of the top-level ``profiles`` section: .. literalinclude :: ../../cats/config.yml @@ -106,6 +106,6 @@ at the command line: --profile my_gpu_profile --gpu 4 --cpu 1 .. warning:: - The ``--profile`` option is optional. Is not provided, ``cats`` uses the + The ``--profile`` option is optional. If not provided, ``cats`` uses the first profile defined in the configuration file as the default profile. From 16b4d97a16bf2b99ee82ab2d9b5c033ed95537d2 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Fri, 5 Jul 2024 15:53:52 +0100 Subject: [PATCH 3/8] Bump version to 1.0.0, add classifiers --- docs/source/conf.py | 2 +- pyproject.toml | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index d899a5e..6ffd852 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -26,7 +26,7 @@ author = authors copyright = f"2023, {authors}" # The full version, including alpha/beta/rc tags -release = "0.1.0" +release = "1.0.0" # Add media: image for logo and a favicon for the browser tab html_logo = "_static/cats_dalle_img_200x200px_for_logo.png" diff --git a/pyproject.toml b/pyproject.toml index 6d03e88..93ab0ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ [project] name = "climate-aware-task-scheduler" - version = "1.0rc1" + version = "1.0.0" description = "Climate aware task scheduler" authors = [ { name = "Colin Sauze" }, @@ -25,7 +25,14 @@ license = { file = "LICENSE" } requires-python = ">=3.9" readme = "README.md" - classifiers = ["License :: OSI Approved :: MIT License"] + classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Science/Research", + "Intended Audience :: System Administrators", + ] dependencies = ["requests-cache>=1.0", "PyYAML>=6.0"] [project.optional-dependencies] From 1587637dc37b4cebb6ece8f816cc55fba0790eb0 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Fri, 5 Jul 2024 16:14:19 +0100 Subject: [PATCH 4/8] docs: simplify API reference section, remove empty modules --- docs/source/api-reference.rst | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/source/api-reference.rst b/docs/source/api-reference.rst index 562e1ba..53c6697 100644 --- a/docs/source/api-reference.rst +++ b/docs/source/api-reference.rst @@ -11,16 +11,10 @@ please see :ref:`cli-reference`. Modules ------- -``cats.__init__`` +``cats`` ^^^^^^^^^^^^^^^^^ -.. automodule:: cats.__init__ - :members: - -``cats.__main__`` -^^^^^^^^^^^^^^^^^ - -.. automodule:: cats.__main__ +.. automodule:: cats :members: ``cats.configure`` From 574189abeb85fe5a9c564224c7de58886069432e Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Thu, 18 Jul 2024 12:48:31 +0100 Subject: [PATCH 5/8] Make version in pyproject.toml and docs dynamic Also report __version__ in help message --- cats/__init__.py | 6 +++++- docs/source/conf.py | 4 +++- pyproject.toml | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cats/__init__.py b/cats/__init__.py index fb2b46c..6045781 100644 --- a/cats/__init__.py +++ b/cats/__init__.py @@ -15,6 +15,8 @@ from .forecast import CarbonIntensityAverageEstimate from .optimise_starttime import get_avg_estimates # noqa: F401 +__version__ = "1.0.0" + # To add a scheduler, add a date format here # and create a scheduler_(...) function SCHEDULER_DATE_FORMAT = {"at": "%Y%m%d%H%M"} @@ -29,7 +31,9 @@ def parse_arguments(): Parse command line arguments :return: [dict] parsed arguments """ - description_text = """ + description_text = f""" + Climate-Aware Task Scheduler (version {__version__}) + -------------------------------------------------------------------------- The Climate-Aware Task Scheduler (cats) command line program helps you run your calculations in a way that minimises their impact on the climate by delaying computation until a time when the ammount of CO2 produced to diff --git a/docs/source/conf.py b/docs/source/conf.py index 6ffd852..15d5cc9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,6 +12,8 @@ import os import sys +import cats + sys.path.insert(0, os.path.abspath("../..")) # cats repo root directory @@ -26,7 +28,7 @@ author = authors copyright = f"2023, {authors}" # The full version, including alpha/beta/rc tags -release = "1.0.0" +release = cats.__version__ # Add media: image for logo and a favicon for the browser tab html_logo = "_static/cats_dalle_img_200x200px_for_logo.png" diff --git a/pyproject.toml b/pyproject.toml index 93ab0ac..8afcd9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] - requires = ['setuptools>=40.8.0'] + requires = ['setuptools>=61.0.0'] build-backend = 'setuptools.build_meta' [tool.setuptools] @@ -8,7 +8,7 @@ [project] name = "climate-aware-task-scheduler" - version = "1.0.0" + dynamic = ["version"] description = "Climate aware task scheduler" authors = [ { name = "Colin Sauze" }, @@ -35,6 +35,9 @@ ] dependencies = ["requests-cache>=1.0", "PyYAML>=6.0"] + [tool.setuptools.dynamic] + version = {attr = "cats.__version__"} + [project.optional-dependencies] test = ["pytest", "numpy>=1.5.0", "pytest-subprocess==1.5.0", "pytest-cov"] types = ["mypy", "types-PyYAML", "types-redis", "types-requests", "types-ujson"] From 20fbc4882cdb48d324ce3b4676db96e0d234b95d Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Thu, 18 Jul 2024 12:51:13 +0100 Subject: [PATCH 6/8] Move docs requirements to pyproject.toml --- .github/workflows/docs-build-deploy.yml | 6 ++---- docs/docs-requirements.txt | 5 ----- pyproject.toml | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 docs/docs-requirements.txt diff --git a/.github/workflows/docs-build-deploy.yml b/.github/workflows/docs-build-deploy.yml index 7cc8d78..9c1023b 100644 --- a/.github/workflows/docs-build-deploy.yml +++ b/.github/workflows/docs-build-deploy.yml @@ -11,10 +11,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - - name: Install cats - run: python3 -m pip install . - - run: | - pip install -r docs/docs-requirements.txt + - name: Install cats with documentation helpers + run: python3 -m pip install '.[docs]' - name: Build sphinx docs run: make -C docs html - name: Deploy sphinx docs diff --git a/docs/docs-requirements.txt b/docs/docs-requirements.txt deleted file mode 100644 index c5197c9..0000000 --- a/docs/docs-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -sphinx -sphinx-argparse -ghp-import -renku-sphinx-theme -sphinx_copybutton diff --git a/pyproject.toml b/pyproject.toml index 8afcd9c..2052777 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ [project.optional-dependencies] test = ["pytest", "numpy>=1.5.0", "pytest-subprocess==1.5.0", "pytest-cov"] types = ["mypy", "types-PyYAML", "types-redis", "types-requests", "types-ujson"] + docs = ["sphinx", "sphinx-argparse", "ghp-import", "renku-sphinx-theme", "sphinx_copybutton"] [project.urls] Home = "https://github.com/GreenScheduler/cats" From 6844ef2120f55663e2508f0bcfd46d7ffcdc8e6c Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Thu, 18 Jul 2024 12:53:43 +0100 Subject: [PATCH 7/8] docs: add pip command for stable version --- docs/source/installation.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 14f1796..24916c4 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -8,4 +8,10 @@ Install CATS via pip as follows: .. code-block:: console :caption: *Command to install CATS with pip.* + $ pip install climate-aware-task-scheduler + +To install the development version + +.. code-block:: console + $ pip install git+https://github.com/GreenScheduler/cats From 9520d283be38f5844a5f6eb0920b7002f903bf75 Mon Sep 17 00:00:00 2001 From: Abhishek Dasgupta Date: Thu, 18 Jul 2024 15:02:26 +0100 Subject: [PATCH 8/8] Update trove tag to production/stable Co-authored-by: Sadie L. Bartholomew --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2052777..f973fa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Science/Research", "Intended Audience :: System Administrators",