From 640a7473a7f9cb5dd9a11dc586b7c887988d4c54 Mon Sep 17 00:00:00 2001 From: Alejandro de la Vega Date: Wed, 30 Mar 2022 12:13:52 -0500 Subject: [PATCH] Test DataLad progress --- neuroscout_cli/cli.py | 35 +++++++++++++++++++++++++++ neuroscout_cli/commands/get.py | 44 ++++++++++++++++++++++++++++++---- 2 files changed, 74 insertions(+), 5 deletions(-) diff --git a/neuroscout_cli/cli.py b/neuroscout_cli/cli.py index 02532f2..dd0237b 100644 --- a/neuroscout_cli/cli.py +++ b/neuroscout_cli/cli.py @@ -106,3 +106,38 @@ def upload(**kwargs): """ from neuroscout_cli.commands import Upload sys.exit(Upload(kwargs).run()) + + +@main.command() +def progress(**kwargs): + """ Upload results. + + This command can be used to upload existing results to NeuroVault. + + Note: `run` automatically calls `upload` after execution, by default. + """ + from tqdm import tqdm + from time import sleep + from datalad.log import is_interactive + from datalad.config import ConfigManager + from datalad.ui import ui + + cfg = ConfigManager() + print(f"Datalad thinks: {is_interactive()}") + + print(f"{cfg.obtain('datalad.tests.ui.backend')}") + print(f"{ui.backend}") + print(f"{ui.ui}") + print(f"Datalad thinks: {ui.is_interactive}") + + + pb = ui.ui.get_progressbar(label='test', unit='s', total=1000) + + print("Datalad:") + for i in tqdm(range(1000)): + pb.update(1) + sleep(0.001) + + print("TQDM:") + for i in tqdm(range(1000)): + sleep(0.001) diff --git a/neuroscout_cli/commands/get.py b/neuroscout_cli/commands/get.py index d0dd183..004275f 100644 --- a/neuroscout_cli/commands/get.py +++ b/neuroscout_cli/commands/get.py @@ -8,13 +8,11 @@ from packaging import version from neuroscout_cli.commands.base import Command from neuroscout_cli import __version__ as VERSION -from datalad.api import install, get, unlock -import datalad +from datalad.api import install, get + from bids.utils import convert_JSON from ..tools.convert import check_convert_model - -datalad.ui.ui.set_backend('console') - + class Get(Command): ''' Command for retrieving neuroscout bundles and their corresponding @@ -32,6 +30,33 @@ def __init__(self, options): def download_bundle(self): + + from tqdm import tqdm + from time import sleep + from datalad.ui import ui + import datalad + + print(datalad.__version__) + + print(f"{ui.backend}") + print(f"{ui.ui}") + print(f"Datalad thinks: {ui.is_interactive}") + + print("TQDM works:") + for i in tqdm(range(1000)): + sleep(0.001) + + pbar = ui.get_progressbar(total=1000) + + print("Datalad:") + pbar.start() + for i in range(1000): + pbar.update(i) + sleep(0.001) + + pbar.finish() + + """ Download analysis bundle and setup preproc dir """ # If tarball doesn't exist, download it bundle_tarball = self.bundle_dir / f'{self.bundle_id}.tar.gz' @@ -70,6 +95,15 @@ def download_bundle(self): # Use datalad to install the preproc dataset install(source=self.resources['preproc_address'], path=str(self.dataset_dir)) + + from tqdm import tqdm + from time import sleep + from datalad.config import ConfigManager + from datalad.ui import ui + + print(f"{ui.backend}") + print(f"{ui.ui}") + print(f"Datalad thinks: {ui.is_interactive}") # Set preproc dir to specific directory, depending on contents for option in ['preproc', 'fmriprep']: