Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release #659

Merged
merged 103 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
c096f74
added functionality
rv0lt Sep 26, 2023
2bcf8be
black
rv0lt Sep 26, 2023
64e8583
black
rv0lt Sep 26, 2023
c5b27ea
sprintlog
rv0lt Sep 27, 2023
56cc6ed
tests
rv0lt Sep 27, 2023
9df4ec8
black
rv0lt Sep 27, 2023
21956fd
tests
rv0lt Sep 27, 2023
91c0906
tests
rv0lt Sep 27, 2023
4ae6af1
tests
rv0lt Sep 27, 2023
bf2d7fe
tests
rv0lt Sep 27, 2023
63461f7
more test
rv0lt Sep 28, 2023
b54ef77
forgot atributes
rv0lt Sep 28, 2023
5e4d662
increase coverage
rv0lt Sep 28, 2023
b7965a8
fix test
rv0lt Sep 28, 2023
b85d480
log test
rv0lt Sep 28, 2023
1fea1d0
more coverage
rv0lt Sep 28, 2023
c6bcf77
refactoring
rv0lt Sep 28, 2023
cd81e61
go back
rv0lt Sep 28, 2023
6c54981
go back
rv0lt Sep 28, 2023
a2dc1e9
init refactoring
rv0lt Sep 28, 2023
dac649f
init refactoring
rv0lt Sep 28, 2023
8a260b3
ref
rv0lt Sep 28, 2023
61ed206
typo
rv0lt Sep 28, 2023
8ab5498
generalise
rv0lt Sep 28, 2023
faf409c
typo
rv0lt Sep 28, 2023
17c8693
typo
rv0lt Sep 28, 2023
fc1375b
updated PR template to match the dds_web one, slightly updated
i-oden Sep 28, 2023
b4d4444
refactore project info
rv0lt Sep 28, 2023
650c86d
forgot ddelete
rv0lt Sep 28, 2023
c3f5dd6
black
rv0lt Sep 28, 2023
992188a
last test
rv0lt Sep 28, 2023
61030a4
links
i-oden Sep 28, 2023
a0fc192
prettier
i-oden Sep 28, 2023
1065a1c
Merge pull request #658 from ScilifelabDataCentre/update-pr-template
i-oden Sep 28, 2023
9827604
feedback
rv0lt Sep 28, 2023
86dfef8
added test
rv0lt Sep 28, 2023
107ddaa
increase coverage
rv0lt Sep 28, 2023
fda09d3
Update SPRINTLOG.md
rv0lt Sep 28, 2023
bf23438
Update dds_cli/base.py
rv0lt Sep 29, 2023
ac25de6
feedback
rv0lt Sep 29, 2023
d1cd87b
black
rv0lt Sep 29, 2023
966c5df
msg
rv0lt Sep 29, 2023
46bd144
black
rv0lt Sep 29, 2023
1b3c860
pylint
rv0lt Sep 29, 2023
ff3288d
Merge branch 'dev' into DDS-1401-Print-project-info-when-deleting-arc…
rv0lt Sep 29, 2023
d70a3bf
Merge pull request #655 from ScilifelabDataCentre/DDS-1401-Print-proj…
rv0lt Sep 29, 2023
b995218
started command
rv0lt Oct 16, 2023
89c7144
second call
rv0lt Oct 16, 2023
c0def91
version and changelog
i-oden Oct 17, 2023
e31d1da
pr template
i-oden Oct 17, 2023
a0dcb1a
Generate new screengrabs with rich-codex
github-actions[bot] Oct 17, 2023
b8acc9a
prettier
i-oden Oct 17, 2023
35a839e
sprintlog
i-oden Oct 17, 2023
5d173a7
release docs
i-oden Oct 17, 2023
a4f48a7
update pr template
i-oden Oct 17, 2023
1ae13a2
new release info
i-oden Oct 17, 2023
0f58043
added tests
rv0lt Oct 17, 2023
363f153
docstring
rv0lt Oct 17, 2023
2e25400
pylint
rv0lt Oct 17, 2023
4a12d23
tests!
rv0lt Oct 17, 2023
9b27bda
missing test
rv0lt Oct 17, 2023
7503833
missing test
rv0lt Oct 17, 2023
baaa98f
sprintlog
rv0lt Oct 17, 2023
ed779e8
prettier
rv0lt Oct 18, 2023
67db194
better coments
rv0lt Oct 18, 2023
b8cc80b
line too long
rv0lt Oct 18, 2023
b045419
changed
rv0lt Oct 19, 2023
17419e3
sprintlog
rv0lt Oct 19, 2023
18f6a7a
Update SPRINTLOG.md
rv0lt Oct 19, 2023
3364935
prettier
rv0lt Oct 19, 2023
2d7cc6f
Merge pull request #662 from ScilifelabDataCentre/DDS-1697-Change-Che…
rv0lt Oct 19, 2023
31fbb36
Merge branch 'dev' into DDS-1690-New-CLI-command-dds-project-status-e…
rv0lt Oct 19, 2023
9167102
prettier
rv0lt Oct 19, 2023
f5829a0
Update SPRINTLOG.md
rv0lt Oct 20, 2023
fd469d7
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
86039bd
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
68d317c
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
0256f85
latest from dev
i-oden Oct 20, 2023
12889d5
changelog
i-oden Oct 20, 2023
c907e48
changelog
i-oden Oct 20, 2023
f83a1cf
feedback
rv0lt Oct 20, 2023
06949d5
pylint
rv0lt Oct 20, 2023
f047fb0
pylint
rv0lt Oct 20, 2023
3f514d3
pylint
rv0lt Oct 20, 2023
c1206f7
Update dds_cli/__main__.py
rv0lt Oct 20, 2023
42cd8bd
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
ddb2db7
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
12ade91
Update dds_cli/project_status.py
rv0lt Oct 20, 2023
693155a
feedback
rv0lt Oct 23, 2023
59e42f7
Update dds_cli/project_status.py
rv0lt Oct 23, 2023
ff58777
Update dds_cli/project_status.py
rv0lt Oct 23, 2023
d81c251
Update dds_cli/project_status.py
rv0lt Oct 23, 2023
61835ab
Update dds_cli/project_status.py
rv0lt Oct 23, 2023
2f10d1f
feedback
rv0lt Oct 23, 2023
8a20679
Update dds_cli/project_status.py
rv0lt Oct 23, 2023
ea57cef
black
rv0lt Oct 23, 2023
a47159b
Update dds_cli/project_status.py
rv0lt Oct 24, 2023
eaa7e4a
format date
rv0lt Oct 24, 2023
932963d
Merge pull request #661 from ScilifelabDataCentre/DDS-1690-New-CLI-co…
rv0lt Oct 24, 2023
431fe34
Merge branch 'dev' into DDS-1701-new-release-for-cli
i-oden Oct 24, 2023
3aef289
changelog
i-oden Oct 24, 2023
d370e4d
Merge pull request #660 from ScilifelabDataCentre/DDS-1701-new-releas…
i-oden Oct 24, 2023
871caf6
Merge branch 'master' into dev
i-oden Oct 24, 2023
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
163 changes: 89 additions & 74 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,94 @@
## Before submitting this PR
## Read this before submitting the PR

1. **Description:** _Add a summary of the changes in this PR and the related issue._
2. **Jira task / GitHub issue:** _Link to the github issue or add the Jira task ID here._
3. **How to test:** _Add information on how someone could manually test this functionality. As detailed as possible._
4. **Type of change:** [_Check the relevant boxes in the section below_](#what-type-of-changes-does-the-pr-contain)
5. **Add docstrings and comments to code**, _even if_ you personally think it's obvious.
1. Always create a Draft PR first
2. Go through sections 1-5 below, fill them in and check all the boxes
3. Make sure that the branch is updated; if there's an "Update branch" button at the bottom of the PR, rebase or update branch.
4. When all boxes are checked, information is filled in, and the branch is updated: mark as Ready For Review and tag reviewers (top right)
5. Once there is a submitted review, implement the suggestions (if reasonable, otherwise discuss) and request an new review.

## What _type of change(s)_ does the PR contain?
If there is a field which you are unsure about, enter the edit mode of this description or go to the [PR template](https://github.com/ScilifelabDataCentre/dds_cli/blob/dev/.github/pull_request_template.md); There are invisible comments providing descriptions which may be of help.

<!--
- "Breaking": The change will cause existing functionality to not work as expected.
- Workflow: E.g. a new github action or changes to this PR template. Anything that alters our or the codes workflow.
-->
## 1. Description / Summary

_Add a summary of the changes in this PR and the related issue._

## 2. Jira task / GitHub issue

_Link to the github issue or add the Jira task ID here._

## 3. Type of change

What _type of change(s)_ does the PR contain?

**Check the relevant boxes below. For an explanation of the different sections, enter edit mode of this PR description template.**

- [ ] New feature
- [ ] Breaking: _Please describe the reason for the break and how we can fix it._
- [ ] Non-breaking
- [ ] Bug fix
- [ ] Breaking: _Please describe the reason for the break and how we can fix it._
- [ ] Non-breaking
- [ ] Security Alert fix
- [ ] Documentation
- [ ] Tests **(only)**
- [ ] Workflow

## Checklist

- [Sprintlog](../SPRINTLOG.md)
- [ ] Added
- [ ] Not needed (E.g. PR contains _only_ tests)
- Rebase / Update / Merge _from_ base branch (the branch from which the current is forked)
- [ ] Done
- [ ] Not needed
- Blocking PRs
- [ ] Merged
- [ ] No blocking PRs
- PR to `master` branch
- [ ] Yes: Read [the release instructions](../docs/procedures/new_release.md)
- [ ] I have followed steps 1-7.
- [ ] No

## Actions / Scans

<!-- Go through all checkboxes. All actions must pass before merging is allowed.-->

- **Black**: Python code formatter. Does not execute. Only tests.
Run `black .` locally to execute formatting.
- [ ] Passed
- **Pylint**: Python code linter. Does not execute. Only tests.
Fix code producing warnings. Code must get 10/10.
- [ ] Warnings fixed
- [ ] Passed
- **Prettier**: General code formatter. Our use case: MD and yaml mainly.
Run `npx prettier --write .` locally to execute formatting.
- [ ] Passed
- **Yamllint**: Linting of yaml files.
- [ ] Passed
- **Tests**: Pytest to verify that functionality works as expected.
- [ ] New tests added
- [ ] No new tests
- [ ] Passed
- **TestPyPi**: Build CLI and publish to TestPyPi in order to verify before release.
- [ ] Passed
- **CodeQL**: Scan for security vulnerabilities, bugs, errors
- [ ] New alerts: _Go through them and either fix, dismiss och ignore. Add reasoning in items below._
- [ ] Alerts fixed: _What?_
- [ ] Alerts ignored / dismissed: _Why?_
- [ ] Passed
- **Trivy**: Security scanner
- [ ] New alerts: _Go through them and either fix, dismiss och ignore. Add reasoning in items below._
- [ ] Alerts fixed: _What?_
- [ ] Alerts ignored / dismissed: _Why?_
- [ ] Passed
- **Snyk**: Security scanner
- [ ] New alerts: _Go through them and either fix, dismiss och ignore. Add reasoning in items below._
- [ ] Alerts fixed: _What?_
- [ ] Alerts ignored / dismissed: _Why?_
- [ ] Passed
- [ ] Breaking: _Why / How? Add info here._ <!-- Should be checked if the changes in this PR will cause existing functionality to not work as expected. E.g. with the master branch of the `dds_cli` -->
- [ ] Non-breaking <!-- Should be checked if the changes will not cause existing functionality to fail. "Non-breaking" is just an addition of a new feature. -->
- [ ] Database change: _Remember the to include a new migration version, **or** explain here why it's not needed._ <!-- Should be checked when you've changed something in `models.py`. For a guide on how to add the a new migration version, look at the "Database changes" section in the README.md. -->
- [ ] Bug fix <!-- Should be checked when a bug is fixed in existing functionality. If the bug fix also is a breaking change (see above), add info about that beside this check box. -->
- [ ] Security Alert fix <!-- Should be checked if the PR attempts to solve a security vulnerability, e.g. reported by the "Security" tab in the repo. -->
- [ ] Documentation <!-- Should be checked if the PR adds or updates the CLI documentation -- anything in docs/ directory. -->
- [ ] Workflow <!-- Should be checked if the PR includes a change in e.g. the github actions files (dds_cli/.github/*) or another type of workflow change. Anything that alters our or the codes workflow. -->
- [ ] Tests **only** <!-- Should only be checked if the PR only contains tests, none of the other types of changes listed above. -->

## 4. Additional information

- [ ] [Sprintlog](https://github.com/ScilifelabDataCentre/dds_cli/blob/dev/SPRINTLOG.md) <!-- Add a row at the bottom of the SPRINTLOG.md file (not needed if PR contains only tests). Follow the format of previous rows. If the PR is the first in a new sprint, add a new sprint header row (follow the format of previous sprints). -->
- [ ] Blocking PRs <!-- Should be checked if there are blocking PRs or other tasks that need to be merged prior to this. Add link to PR or Jira card if this is the case. -->
- [ ] Merged <!-- Should be checked if the "Blocking PRs" box was checked AND all blocking PRs have been merged / fixed. -->
- [ ] PR to `master` branch: _If checked, read [the release instructions](https://github.com/ScilifelabDataCentre/dds_cli/blob/dev/docs/procedures/new_release.md)_ <!-- Check this if the PR is made to the `master` branch. Only the `dev` branch should be doing this. -->
- [ ] I have followed steps 1-8. <!-- Should be checked if the "PR to `master` branch" box is checked AND the specified steps in the release instructions have been followed. -->

## 5. Actions / Scans

_Check the boxes when the specified checks have passed._

**For information on what the different checks do and how to fix it if they're failing, enter edit mode of this description or go to the [PR template](https://github.com/ScilifelabDataCentre/dds_cli/blob/dev/.github/pull_request_template.md).**

- [ ] **Black**
<!--
What: Python code formatter.
How to fix: Run `black .` locally to execute formatting.
-->
- [ ] **Pylint**
<!--
What: Python code linter.
How to fix: Manually fix the code producing warnings. Code must get 10/10.
-->
- [ ] **Prettier**
<!--
What: General code formatter. Our use case: MD and yaml mainly.
How to fix: Run npx prettier --write . locally to execute formatting.
-->
- [ ] **Yamllint**
<!--
What: Linting of yaml files.
How to fix: Manually fix any errors locally.
-->
- [ ] **Tests**
<!--
What: Pytest to verify that functionality works as expected.
How to fix: Manually fix any errors locally. Follow the instructions in the "Run tests" section of the README.md to run the tests locally.
Additional info: The PR should ALWAYS include new tests or fixed tests when there are code changes. When pytest action has finished, it will post a codecov report; Look at this report and verify the files you have changed are listed. "90% <100.00%> (+0.8%)" means "Tests cover 90% of the changed file, <100 % of this PR's code changes are tested>, and (the code changes and added tests increased the overall test coverage with 0.8%)
-->
- [ ] **TestPyPI**
<!--
What: Builds the CLI and publishes to TestPyPI in order to verify before release.
How to fix: Check the action logs and fix potential issues manually.
-->
- [ ] **CodeQL**
<!--
What: Scan for security vulnerabilities, bugs, errors.
How to fix: Go through the alerts and either manually fix, dismiss or ignore. Add info on ignored or dismissed alerts.
-->
- [ ] **Trivy**
<!--
What: Security scanner.
How to fix: Go through the alerts and either manually fix, dismiss or ignore. Add info on ignored or dismissed alerts.
-->
- [ ] **Snyk**
<!--
What: Security scanner.
How to fix: Go through the alerts and either manually fix, dismiss or ignore. Add info on ignored or dismissed alerts.
-->
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
==========

.. _2.5.2:

2.5.2 - 2023-10-25
~~~~~~~~~~~~~~~~~~~

- Updated command: `dds project status delete/archive` now prints project information and asks for confirmation from user.
- "Checksum verification successful" is not printed when file integrity is verified (unless `-v` option is used); Only prints if there is an error.
- New command `dds project status extend`: Unit Admins / Personnel can extend the project deadline prior to the project expiring.

.. _2.5.1:

2.5.1 - 2023-09-25
Expand Down
9 changes: 8 additions & 1 deletion SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,11 @@ _Nothing merged in CLI during this sprint_

# 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)
- GitHub Actions to generate the documentation fixed ([#650](https://github.com/ScilifelabDataCentre/dds_cli/pull/650))
- Print project information and ask user for confirmation when deleting or archiving projects ([#655](https://github.com/ScilifelabDataCentre/dds_cli/pull/655))

# 2023-10-16 - 2023-10-27

- Change "Checksum verification successful. File integrity verified." logging level from INFO to DEBUG in order to not print for all files ([#662](https://github.com/ScilifelabDataCentre/dds_cli/pull/662)
- New command `dds project status extend` to allow extension of project deadline ([#661](https://github.com/ScilifelabDataCentre/dds_cli/pull/661)
- New version: 2.5.2 ([#660](https://github.com/ScilifelabDataCentre/dds_cli/pull/660))
110 changes: 66 additions & 44 deletions dds_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,28 +1196,22 @@ def archive_project(click_ctx, project: str, abort: bool = False):

Use the `--abort` flag to indicate that something has gone wrong in the project.
"""
proceed_deletion = (
True
if click_ctx.get("NO_PROMPT", False)
else dds_cli.utils.get_deletion_confirmation(action="archive", project=project)
)
if proceed_deletion:
try:
with dds_cli.project_status.ProjectStatusManager(
project=project,
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as updater:
updater.update_status(new_status="Archived", is_aborted=abort)
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.DDSCLIException,
dds_cli.exceptions.ApiResponseError,
dds_cli.exceptions.ApiRequestError,
) as err:
LOG.error(err)
sys.exit(1)
try:
with dds_cli.project_status.ProjectStatusManager(
project=project,
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as updater:
updater.update_status(new_status="Archived", is_aborted=abort)
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.DDSCLIException,
dds_cli.exceptions.ApiResponseError,
dds_cli.exceptions.ApiRequestError,
) as err:
LOG.error(err)
sys.exit(1)


# -- dds project status delete -- #
Expand All @@ -1231,28 +1225,56 @@ def delete_project(click_ctx, project: str):
Certain meta data is kept (nothing sensitive) and it will still be listed in your projects. All
data within the project is deleted. You cannot revert this change.
"""
proceed_deletion = (
True
if click_ctx.get("NO_PROMPT", False)
else dds_cli.utils.get_deletion_confirmation(action="delete", project=project)
)
if proceed_deletion:
try:
with dds_cli.project_status.ProjectStatusManager(
project=project,
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as updater:
updater.update_status(new_status="Deleted")
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.DDSCLIException,
dds_cli.exceptions.ApiResponseError,
dds_cli.exceptions.ApiRequestError,
) as err:
LOG.error(err)
sys.exit(1)
try:
with dds_cli.project_status.ProjectStatusManager(
project=project,
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as updater:
updater.update_status(new_status="Deleted")
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.DDSCLIException,
dds_cli.exceptions.ApiResponseError,
dds_cli.exceptions.ApiRequestError,
) as err:
LOG.error(err)
sys.exit(1)


# -- dds project status extend -- #
@project_status.command(name="extend", no_args_is_help=True)
# Options
@project_option(required=True)
@click.option(
"--new-deadline",
required=False,
type=int,
help="Number of days to extend the deadline.",
)
@click.pass_obj
def extend_deadline(click_ctx, project: str, new_deadline: int):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will result in:

ERROR    Failed to extend project deadline: The method is not allowed for the requested URL.            

when run with the master branch of the dds_web

"""Extend a project deadline by an specified number of days.

It consumes one of allowed times to renew data access.
"""
try:
with dds_cli.project_status.ProjectStatusManager(
project=project,
no_prompt=click_ctx.get("NO_PROMPT", False),
token_path=click_ctx.get("TOKEN_PATH"),
) as updater:
updater.extend_deadline(new_deadline=new_deadline)
except (
dds_cli.exceptions.APIError,
dds_cli.exceptions.AuthenticationError,
dds_cli.exceptions.DDSCLIException,
dds_cli.exceptions.ApiResponseError,
dds_cli.exceptions.ApiRequestError,
) as err:
LOG.error(err)
sys.exit(1)


# -- dds project status busy -- #
Expand Down
37 changes: 37 additions & 0 deletions dds_cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,43 @@ def __exit__(self, exception_type, exception_value, traceback, max_fileerrs: int

return True

# Public methods ############################### Public methods #

def get_project_info(self):
"""Collect project information from API."""

# Get info about a project from API
response, _ = dds_cli.utils.perform_request(
DDSEndpoint.PROJ_INFO,
method="get",
headers=self.token,
params={"project": self.project},
error_message="Failed to get project information",
)

project_info = response.get("project_info")

# If not project info was retrieved from the request, throw an exception
if not project_info:
raise dds_cli.exceptions.ApiResponseError(message="No project information to display.")

return project_info

def generate_project_table(self, project_info):
"""Generate a table from some project info provided"""

# Print project info table
table = dds_cli.utils.create_table(
title="Project information.",
columns=["Project ID", "Created by", "Status", "Last updated", "Size"],
rows=[
project_info,
],
caption=f"Information about project {project_info['Project ID']}",
)

return table

# Private methods ############################### Private methods #
def __get_safespring_keys(self):
"""Get safespring keys."""
Expand Down
2 changes: 1 addition & 1 deletion dds_cli/file_encryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def verify_checksum(file: pathlib.Path, correct_checksum):
else:
if checksum.hexdigest() == correct_checksum:
verified, error = (True, "File integrity verified.")
LOG.info("Checksum verification successful. File integrity verified.")
LOG.debug("Checksum verification successful. File integrity verified.")
else:
error = "Checksum verification failed. File compromised."
LOG.warning(error)
Expand Down
Loading
Loading