Skip to content

Required Corrections and Improvements for CBRAIN CLI Project Completion #28

@MontrealSergiy

Description

@MontrealSergiy

Hello Asif,

As you can see, we merged the pull requests. A few days ago, the CBRAIN team got together and proceeded to review the status of your CBRAIN cli client.

Overall, we are happy with your product. Before the end of the project, we would like just a few more minor bug fixes, which we will document here.

There are also several more important changes that we would like to make to the codebase, but we will take care of them ourselves later on.

We have merged a new list of cbrain cli commands in the file capture_tests/cbrain_cli_commands and provided the corresponding set of expected behavior in the file capture_tests/expected_captures.txt. There are several places in the expected_captures.txt that indicate that the cbrain client needs some adjustments (e.g. it doesn't produce the correct outputs). Once the cbrain cli is updated, you (or CBRAIN team) can adjust the expected_captures.txt file accordingly. Most of the changes are marked with the word TOFIX in expected_captures.txt. For instance, the first appearance is for the command cbrain version which prints an error message when the user is not logged in. CBRAIN team should print the version no matter if the user is logged in or not. Once this is fixed, the GitHub actions framework will run the tests again and we'll have the information to adjust expected_captures.txt.

Here are the other observations we made about your program. Some of them are also documented in the capture file.

  1. There is an important BUG. Several of the cbrain client commands make their requests to the servers two times. For instance, cbrain file show 5 will contact the server two times and ask for the information twice for no reason. This is caused by buggy code in main.py, have a look.
  2. There is an "interactive" mode with the option -i but it only works for tag create. Since this feature is too unique, we recommend you completely remove it. Maybe we will add an interactive version later on.
  3. Many error messages do not end up an standard error, e.g. cbrain file show 99999 prints a message on standard output instead.
  4. Many commands with --json or --jsonl do not return error messages in JSON.
  5. There is no way for the user to switch to the all project. cbrain project switch all could be the command (see also unswitch issue ).
  6. When creating any new object, the server usually returns the information about it (sometimes the object itself). So the program should show this. E.g. when creating a tag, the program should show the tag created in textual or json format if --json option is provided.
  7. User is not able to upload a file without indicating type. Please, either provide clearer error message, or make SingleFile default type.
    cbrain file upload --data-provider 15 --group-id 3 README.md
    Operation failed: 'Namespace' object has no attribute 'file_type'
    
  8. When showing error messages, please show the full usage statement of the subcommand, so user better understand the course of action. E.g. cbrain tag create and all other incomplete tag create command should show the full description for tag create.

Features that we would like to have one day

(These are not necessary for the Google Summer of Code project)

  1. Having multiple sessions. Right now if user(s) want to connect to two different CBRAIN servers, they have to log in and log out and log back in. The main cbrain command could support:
cbrain blah blah blah
cbrain --session prod1  blah blah blah
cbrain --session myserv blah blah blah

and the cbrain command would store in ~/.config/cbrain.json two distinct session structures, something like this:

{
  "default": {
    "cbrain_url": "http://localhost:3000",
    "api_token":  "0123456789abcdeffedcba9876543210",
    "user_id":    5,
    "timestamp":  "2025-08-24T18:18:10"
  },
  "prod1": {
 "prod1": {
    "cbrain_url": "https://portal.cbrain.mcgill.ca",
    "api_token":  "0123456789abcdeffedcba9876543210",
    "user_id":    8,
    "timestamp":  "2025-08-24T18:18:10"
  },
  "myserv": {
    "cbrain_url": "http://localhost:3001",
    "api_token":  "0123456789abcdeffedcba9876543210",
    "user_id":    2,
    "timestamp":  "2025-08-24T18:18:10"
  }
}
  1. Add a local README file for the top level folders
    data and formatter
  2. Make sure we stay consistent with group vs project
    and dataprovider vs data-provider (etc).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions