Skip to content

Commit

Permalink
Merge pull request #653 from ScilifelabDataCentre/dev
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
i-oden authored Sep 25, 2023
2 parents 7dfc0d8 + 799edac commit 13db8e3
Show file tree
Hide file tree
Showing 19 changed files with 657 additions and 417 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs-github-pages-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Build the DDS CLI Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Make dependencies available to Docker container
run: |
cat requirements.txt requirements-dev.txt > ./docs/requirements.txt
Expand All @@ -24,7 +24,7 @@ jobs:
build-command: "make dirhtml"
docs-folder: "docs/"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4.2.5
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: docs/_build/dirhtml/
13 changes: 7 additions & 6 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ jobs:
if: github.repository == 'ScilifelabDataCentre/dds_cli'
uses: pypa/gh-action-pypi-publish@release/v1
with:
print_hash: true
print-hash: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Publish dist to PyPI
if: github.repository == 'ScilifelabDataCentre/dds_cli'
uses: pypa/gh-action-pypi-publish@release/v1
with:
print_hash: true
print-hash: true
user: __token__
password: ${{ secrets.pypi_password }}
skip_existing: true
skip-existing: true

ddsclibinaries:
name: Build binary packages for the DDS CLI
Expand Down Expand Up @@ -132,13 +132,14 @@ jobs:
uses: matthiaszepper/sphinx-action-v4@latest
with:
container: latest
pre-build-command: "pip install ."
pre-build-command: "apt-get update && apt-get install -y gcc && pip install ."
build-command: "make html"
docs-folder: "docs/"
- name: Build the pdf with Sphinx
uses: matthiaszepper/sphinx-action-v4@pdflatex
with:
container: pdflatex
pre-build-command: "apt-get update && apt-get install -y librsvg2-bin"
build-command: "make latexpdf"
docs-folder: "docs/"
- name: Create an artifact of the previously built HTML
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Changelog
==========

.. _2.5.1:

2.5.1 - 2023-09-25
~~~~~~~~~~~~~~~~~~~

- Super Admins only:
- New command: `dds maintenance status` to check if maintenance mode is on or off
- Updated command: `dds stats` now prints two separate tables with the stats collected from the API
- Dependencies:
- `requests` from `2.28.1` to `2.31.0`
- Documentation:
- Generation of PDF format fixed

.. _2.5.0:

2.5.0 - 2023-08-29
Expand Down
11 changes: 11 additions & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,14 @@ _Nothing merged in CLI during this sprint_
- Print understandable message when request response doesn't contain json ([#638](https://github.com/ScilifelabDataCentre/dds_cli/pull/638))
- New option in `dds user ls`: `--save-emails` for Super Admins to save emails to file ([#641](https://github.com/ScilifelabDataCentre/dds_cli/pull/641))
- New version: 2.5.0 ([#646](https://github.com/ScilifelabDataCentre/dds_cli/pull/646))
- New command `dds maintenance status` for Super Admins to check current Maintenance mode status ([#644](https://github.com/ScilifelabDataCentre/dds_cli/pull/644))
- Workflow: Github Pages action fixed by bumping versions ([#648](https://github.com/ScilifelabDataCentre/dds_cli/pull/648))

# 2023-09-04 - 2023-09-15

- Updated command: `dds stats` prints tables with stats collected from API ([#643](https://github.com/ScilifelabDataCentre/dds_cli/pull/643))
- Dependency: Bump `requests` to 2.31.0 ([#649](https://github.com/ScilifelabDataCentre/dds_cli/pull/649))

# 2023-09-18 - 2023-09-29

- GitHub Actions to generate the documentation fixed ([#1473])(https://scilifelab.atlassian.net/jira/software/projects/DDS/boards/13?selectedIssue=DDS-1473)
3 changes: 3 additions & 0 deletions dds_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class DDSEndpoint:
# Activate / deactivate Maintenance mode
MAINTENANCE = BASE_ENDPOINT + "/maintenance"

# Get statistics
STATS = BASE_ENDPOINT + "/stats"

TIMEOUT = 120


Expand Down
48 changes: 17 additions & 31 deletions dds_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import itertools
import logging
import sys
import typing

# Installed
import pathlib
Expand All @@ -27,7 +26,7 @@
import dds_cli.account_manager
import dds_cli.unit_manager
import dds_cli.motd_manager
import dds_cli.maintenance_manager
import dds_cli.superadmin_helper
import dds_cli.data_getter
import dds_cli.data_lister
import dds_cli.data_putter
Expand Down Expand Up @@ -2077,17 +2076,23 @@ def send_motd(click_ctx, motd_id):

@dds_main.command(name="maintenance", no_args_is_help=True)
@click.argument(
"setting", metavar="[ON/OFF]", nargs=1, type=click.Choice(["on", "off"], case_sensitive=False)
"setting",
metavar="[ON/OFF/STATUS]",
nargs=1,
type=click.Choice(["on", "off", "status"], case_sensitive=False),
)
@click.pass_obj
def set_maintenance_mode(click_ctx, setting):
"""[Super Admins only] Activate / Deactivate Maintenance mode."""
def manage_maintenance_mode(click_ctx, setting):
"""[Super Admins only] Activate / Deactivate / Display status for Maintenance mode."""
try:
with dds_cli.maintenance_manager.MaintenanceManager(
with dds_cli.superadmin_helper.SuperAdminHelper(
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as setter:
setter.change_maintenance_mode(setting=setting)
) as manager:
if setting == "status":
manager.display_maintenance_mode_status()
else:
manager.change_maintenance_mode(setting=setting)
except (
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.ApiResponseError,
Expand All @@ -2103,35 +2108,16 @@ def set_maintenance_mode(click_ctx, setting):


@dds_main.command(name="stats", no_args_is_help=False)
@click.argument(
"stat_type", nargs=1, type=click.Choice(["active", "all", "size"], case_sensitive=True)
)
@click.pass_obj
def get_stats(click_ctx, stat_type):
def get_stats(click_ctx):
"""Get statistics in the DDS."""
try:
# Num projects
with dds_cli.data_lister.DataLister(
show_usage=True,
with dds_cli.superadmin_helper.SuperAdminHelper(
no_prompt=click_ctx.get("NO_PROMPT", False),
json=True,
token_path=click_ctx.get("TOKEN_PATH"),
) as lister:
# Get projects, only active by default
projects: typing.List = lister.list_projects(show_all=stat_type == "all")

if stat_type == "size":
# Calculate total amount of saved data in active projects
title_bold_part: str = "Bytes"
title_rest: str = "currently stored in DDS"
value: int = sum(x["Size"] for x in projects)
else:
# Get number of projects
title_bold_part: str = "Active" if stat_type == "active" else "Total"
title_rest: str = "projects"
value: int = len(projects)

LOG.info("[bold]%s[/bold] %s: %s", title_bold_part, title_rest, value)
) as helper:
helper.get_stats()
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
Expand Down
71 changes: 0 additions & 71 deletions dds_cli/maintenance_manager.py

This file was deleted.

Loading

0 comments on commit 13db8e3

Please sign in to comment.