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

Improve outputs of project inspection CLI commands #694

Merged
merged 8 commits into from
May 12, 2023

Conversation

juhoinkinen
Copy link
Member

@juhoinkinen juhoinkinen commented Apr 21, 2023

  • Makes the column widths of the output of annif list-projects and annif list-vocabs dynamic to not spend unnecessary space in terminal. For vocabularies the benefit of this is not so great, but implementing this for both listing commands keeps the functionalities aligned. The separator for columns is 2 spaces.

  • Adds vocabulary ID and modification time columns to the output of list-projects implementing issue CLI command list-projects fields #686.

  • Converts the project modification timestamps to current timezone (from UTC) and formats them to YYYY-MM-DD hh:mm:ss in the outputs of list-projects and show-project, using - in place of None.

  • Adds "Backend" line the output of show-project

An example output of list-projects:

Project ID                Project Name                   Vocabulary ID  Language  Trained  Modification time  
--------------------------------------------------------------------------------------------------------------
tfidf-fi                  TF-IDF Finnish                 yso            fi        True     2023-04-21 10:28:37
tfidf-sv                  TF-IDF Swedish                 yso            sv        True     2023-04-21 10:30:17
tfidf-en                  TF-IDF English                 yso            en        True     2023-04-21 10:30:45
fasttext-fi               fastText Finnish               yso            fi        True     2023-04-21 10:33:16
fasttext-sv               fastText Swedish               yso            sv        True     2023-04-21 10:32:25
fasttext-en               fastText English               yso            en        True     2023-04-21 10:31:28
omikuji-parabel-fi        Omikuji Parabel Finnish        yso            fi        True     2023-04-21 10:35:14
omikuji-parabel-sv        Omikuji Parabel Swedish        yso            sv        True     2023-04-21 10:32:12
omikuji-parabel-en        Omikuji Parabel English        yso            en        True     2023-04-21 10:31:47
mllm-fi                   YSO MLLM Finnish               yso            fi        False    -                  
mllm-en                   YSO MLLM English               yso            en        False    -                  
mllm-sv                   YSO MLLM Swedish               yso            sv        False    -                  
yake-fi                   YAKE Finnish                   yso            fi        True     2023-04-21 10:23:56
ensemble-fi               Ensemble Finnish               yso            fi        False    2023-04-21 10:33:16
ensemble-sv               Ensemble Swedish               yso            sv        False    2023-04-21 10:32:25
ensemble-en               Ensemble English               yso            en        False    2023-04-21 10:31:28
ykl-omikuji-parabel-fi    YKL Omikuji Parabel Finnish    ykl            fi        False    -                  
thema-omikuji-parabel-fi  Thema Omikuji Parabel Finnish  thema-fi       fi        False    -                  

An example output of list-vocabs:

Vocabulary ID  Languages    Size   Loaded
-----------------------------------------
yso            en,fi,se,sv  38179  True  
ykl            -            -      False 
thema-fi       -            -      False 

An example output of show-project:

Project ID:        fasttext-fi
Project Name:      fastText Finnish
Language:          fi
Vocabulary:        yso
Vocab language:    fi
Access:            public
Backend:           fasttext
Trained:           True
Modification time: 2023-04-21 10:33:16

@juhoinkinen juhoinkinen added this to the 1.0 milestone Apr 21, 2023
@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (3451bd3) 99.63% compared to head (0cc9fe3) 99.63%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #694   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files          89       89           
  Lines        6222     6253   +31     
=======================================
+ Hits         6199     6230   +31     
  Misses         23       23           
Impacted Files Coverage Δ
annif/cli.py 99.65% <100.00%> (+<0.01%) ⬆️
annif/cli_util.py 98.98% <100.00%> (+0.11%) ⬆️
tests/test_cli.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

dirpath = os.path.join(str(testdatadir), "projects", "tfidf-fi")
fpath = os.path.join(str(dirpath), "test_show_project_datafile")
os.makedirs(dirpath)
open(fpath, "a").close()

Check warning

Code scanning / CodeQL

File is not always closed

File is opened but is not closed.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is a false warning.

@juhoinkinen
Copy link
Member Author

I started to think adding also "Backend" column to the output of list-projects, but maybe that is too much detail in there. But backend could be shown by show-projects.

@juhoinkinen juhoinkinen changed the title Make list commands column widths dynamic and add vocabulary & modif. time fields to list-projects Improve outputs of project inspection CLI commands Apr 21, 2023
@juhoinkinen
Copy link
Member Author

juhoinkinen commented Apr 21, 2023

Yet another addition would be to dump project configuration to output of show-project.

Other possible items to be added to the show-project output have been listed in the old issue #329.

@juhoinkinen juhoinkinen marked this pull request as ready for review April 21, 2023 10:24
@juhoinkinen
Copy link
Member Author

Yet another addition would be to dump project configuration to output of show-project.

The output for project configuration could be like this (hiding the parameters that are already shown by the above lines):

$ annif show-project fasttext-fi 
Project ID:        fasttext-fi
Project Name:      fastText Finnish
Language:          fi
Vocabulary:        yso
Vocab language:    fi
Access:            public
Trained:           True
Modification time: 2023-04-21 10:33:16
Parameters:
  backend:         fasttext
  analyzer:        voikko(fi)
  dim:             500
  lr:              0.25
  epoch:           30
  loss:            hs
  limit:           100
  chunksize:       24

@sonarcloud
Copy link

sonarcloud bot commented Apr 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@juhoinkinen juhoinkinen linked an issue May 4, 2023 that may be closed by this pull request
@juhoinkinen juhoinkinen requested a review from osma May 12, 2023 08:06
Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

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

LGTM

@osma
Copy link
Member

osma commented May 12, 2023

Maybe simplest would be to merge this as it is now, then possibly work on the project configuration display in a follow-up PR?

@juhoinkinen juhoinkinen merged commit 2d1d3ce into main May 12, 2023
@juhoinkinen juhoinkinen deleted the issue686-cli-command-list-projects-fields branch May 12, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI command list-projects fields
2 participants