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

TMP: Test DataLad progress #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions neuroscout_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
44 changes: 39 additions & 5 deletions neuroscout_cli/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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']:
Expand Down