-
Notifications
You must be signed in to change notification settings - Fork 8
Add README for the data and formatter layers.
#40
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
Open
RafsanNeloy
wants to merge
1
commit into
aces:main
Choose a base branch
from
RafsanNeloy:readme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Welcome to the CBRAIN CLI Data Layer! 👋 | ||
|
|
||
| This directory is the core engine connecting our command-line tools to **CBRAIN**—a powerful web-enabled platform built to manage large, distributed research datasets and mediate high-performance computing (HPC) tasks. | ||
|
|
||
| Whenever the CLI needs to talk to CBRAIN's architecture (specifically the **BrainPortal** API), it happens right here. | ||
|
|
||
| ## How It Is Used 🛠️ | ||
|
|
||
| Think of these Python modules as your direct bridge to CBRAIN's resources. They handle all the API calls, data fetching, and object modeling. If a user command needs to interact with the CBRAIN database, these modules do the heavy lifting. | ||
|
|
||
| ### The Modules at a Glance (with Example Commands!): | ||
|
|
||
| * **`background_activities.py`**: Tracks backend jobs in progress (`cbrain background`). | ||
| * *Example:* `cbrain background list` | ||
| * **`data_providers.py`**: Connects to the systems storing your research data (`cbrain dataprovider`). | ||
| * *Example:* `cbrain dataprovider show 15` | ||
| * **`files.py`**: Manages data uploads, caching, and transfers across CBRAIN (`cbrain file`). | ||
| * *Example:* `cbrain file move --file-id 2 --dp-id 15` | ||
| * **`projects.py`**: Keeps user research organized (`cbrain project`). | ||
| * *Example:* `cbrain project switch 10` | ||
| * **`remote_resources.py`**: Interfaces with external network capabilities (`cbrain remote-resource`). | ||
| * *Example:* `cbrain remote-resource list` | ||
| * **`tags.py`**: Organizes and categorizes files and tasks (`cbrain tag`). | ||
| * *Example:* `cbrain tag create --name NewTag1 --user-id 2 --group-id 3` | ||
| * **`tasks.py`**: Orchestrates intensive compute jobs on remote HPCs (`cbrain task`). | ||
| * *Example:* `cbrain task show 2` | ||
| * **`tools.py` & `tool_configs.py`**: Manages the scientific tools available on CBRAIN (`cbrain tool` / `cbrain tool-config`). | ||
| * *Example:* `cbrain tool list` | ||
|
|
||
| ## How It Fits Together 🧩 | ||
|
|
||
| **Data here, Display there.** | ||
|
|
||
| This folder is strictly for fetching raw objects from the CBRAIN server. Once we pull the data, we hand it off to the `formatter/` directory, which takes those raw responses and turns them into clean, human-readable outputs for your terminal! | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Welcome to the CBRAIN CLI Formatter Layer! 🎨 | ||
|
|
||
| This directory is all about **presentation**. Once the CLI fetches raw data objects from the CBRAIN backend (using the `data/` modules), it hands them over to these formatter scripts to make them look great in your terminal. | ||
|
|
||
| These formatters are responsible for creating the clean tables, organized summaries, and human-readable text you see when you run a command. | ||
|
|
||
| ## How It Fits Together 🧩 | ||
|
|
||
| **Data there, Display here.** | ||
|
|
||
| While the `data/` directory handles backend API interactions, the `formatter/` directory focuses exclusively on presenting that info. Every `_fmt.py` file here perfectly matches a corresponding data module. For example, `tasks.py` gets the data, and `tasks_fmt.py` decides how to draw it on your screen! | ||
|
|
||
| ## What the Formatter Actually Does 🪄 | ||
|
|
||
| Imagine you ask CBRAIN for a list of your files using `cbrain file list`. The raw data coming from the server is a dense machine-readable bundle filled with IDs, timestamps, and metadata. | ||
|
|
||
| Instead of throwing that raw JSON at you, the formatter layer catches the data and turns it into a beautiful, easy-to-read table right in your terminal. Here is exactly what these scripts do: | ||
|
|
||
| **The Raw Data (what `data/` gets):** | ||
| ```json | ||
| {"id": 1024, "name": "my_mri_scan.nii.gz", "size": 47185920, "status": "synced"} | ||
| ``` | ||
|
|
||
| **The Formatted Output (what `formatter/` shows you):** | ||
| ```text | ||
| +---------+----------------------+---------+-------------+ | ||
| | File ID | Name | Size | Status | | ||
| +---------+----------------------+---------+-------------+ | ||
| | 1024 | my_mri_scan.nii.gz | 45.0 MB | Synced | | ||
| +---------+----------------------+---------+-------------+ | ||
| ``` | ||
|
|
||
| *(Fun fact: We don't use heavy external libraries like `PrettyTable` or `Rich` for this! The CLI uses a custom-built, lightweight, dynamic table formatter powered completely by Python's built-in `textwrap` and `shutil` libraries. That means zero extra dependencies to slow you down!)* | ||
|
|
||
| Every `_fmt.py` script in this folder is basically a tiny artist that knows exactly how to draw its specific type of data so it's perfectly readable for you! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to hyperlink of this file or this is okay?