core

kuut and kstep

kstep

/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Attributes
  else: warn(msg)
/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Methods
  else: warn(msg)

source

kstep

 kstep (num:int, sub:Optional[int]=None, val:Optional[int]=1,
        desc:Optional[str]=None)

A dataclass to store step information.

Type Default Details
num int The main number of the step.
sub Optional None The sub number of the step, if it exists.
val Optional 1 The value of the step.
desc Optional None A description for the step.

Step Examples

(
    step_1.is_sub(step_1_0),
    step_1_0.is_sub(step_1),
    step_1_0.is_sub(step_1_0), 
    step_1_0.is_sub(step_2), 
    step_1_0.is_sub(step_3_0), 
)
(False, True, True, False, False)

kuut


source

kuut

 kuut (*args, **kwargs)

A progress bar class that extends tqdm and operates with kstep instances.

Basic Examples

# create a list of steps
steps = [kstep(num=i, sub=i+1, val=i+2, desc=f"Step {i}") for i in range(10)]

# create a kuut instance
pbar = kuut(steps=steps, display=False)

# use the properties
(
    pbar.pbar_total, # outputs: 65
    pbar.step_nums,  # outputs: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    pbar.num_main_steps  # outputs: 10
)
(65, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 10)
(
    pbar.does_step_exist(5, 6), # outputs: True
    pbar.does_step_exist(5), # outputs: False
    pbar.get_step(5, 6) # outputs: kstep(num=5, sub=6, val=7, desc='Step 5')
)
(True, False, kstep(num=5, sub=6, val=7, desc='Step 5'))
pbar.container
pbar.step(5, 6) # outputs: Step 5.6
import time
pbar = kuut(steps=steps)
for _ in pbar:
    # Simulate some work
    time.sleep(0.1)
    pbar.step(_.num, _.sub)

Complex Example

steps = [
        kstep(1, val=20, desc='download'),
        kstep(2, sub=0, val=5, desc='load_timepoints'),
        kstep(2, sub=1, val=5, desc='load_timepoints'),
        kstep(2, sub=2, val=5, desc='load_timepoints'),
        kstep(2, sub=3, val=5, desc='load_timepoints'),
        kstep(2, sub=4, val=5, desc='load_timepoints'),
        # kstep(2, val=25, desc='load_timepoints'),
        kstep(3, sub=0, val=5, desc='library_fitlering'),
        kstep(3, sub=1, val=5, desc='library_fitlering'),
        kstep(3, sub=2, val=5, desc='library_fitlering'),
        kstep(3, sub=3, val=5, desc='library_fitlering'),
        kstep(3, sub=4, val=5, desc='library_fitlering'),
        # kstep(3, val=25, desc='library_fitlering'),
        kstep(4, val=5, desc='merge_data'),
        kstep(5, sub=0, val=5, desc='filter_data'),
        kstep(5, sub=1, val=5, desc='filter_data'),
        kstep(5, sub=2, val=5, desc='filter_data'),
        kstep(5, sub=3, val=5, desc='filter_data'),
        kstep(5, sub=4, val=5, desc='filter_data'),
        kstep(5, sub=5, val=5, desc='filter_data'),
        # kstep(5, val=30, desc='filter_data'),
        kstep(6, val=20, desc='embed'),
        kstep(7, desc='save'),
    ]
k = kuut(steps, desc='test', display=False)
k.container
k.step(2)