Ejemplo n.º 1
0
def test_recover_then_rerun(mapped_doubler):
    m = mapped_doubler.map([1], tag='load-then-rerun')
    m.wait(timeout=180)

    loaded = htmap.load('load-then-rerun')
    loaded.rerun()

    assert list(loaded) == [2]
Ejemplo n.º 2
0
def test_load_then_rerun(mapped_doubler):
    m = mapped_doubler.map([1], tag="load-then-rerun")
    m.wait()

    loaded = htmap.load("load-then-rerun")
    loaded.rerun()

    assert list(loaded) == [2]
Ejemplo n.º 3
0
def _cli_load(tag: str) -> htmap.Map:
    with make_spinner(text=f'Loading map {tag}...') as spinner:
        try:
            return htmap.load(tag)
        except Exception as e:
            spinner.fail()
            click.echo(f'ERROR: could not find a map with tag {tag}', err=True)
            click.echo(f'Your map tags are:', err=True)
            click.echo(_tag_list(), err=True)
            sys.exit(1)
Ejemplo n.º 4
0
def _cli_load(tag: str) -> htmap.Map:
    with make_spinner(text=f"Loading map {tag}...") as spinner:
        try:
            return htmap.load(tag)
        except Exception as e:
            spinner.fail()
            logger.exception(f"Could not find a map with tag {tag}")
            click.echo(f"ERROR: could not find a map with tag {tag}", err=True)
            click.echo(f"Your map tags are:", err=True)
            click.echo(_fmt_tag_list(), err=True)
            sys.exit(1)
Ejemplo n.º 5
0
def main(tag, outdir):
    with make_spinner(f"loading map {tag}...") as spinner:
        map = htmap.load(tag)
        spinner.succeed(f"loaded map {tag}")

    if outdir is None:
        outdir = Path.cwd()
    outdir = Path(outdir)
    outpath = outdir / f"{tag}.sims"

    try:
        with si.utils.BlockTimer() as timer:
            with gzip.open(outpath, mode="wb") as f:
                pickle.dump(len(map), f)
                for sim in tqdm(map, desc="pickling sims...", total=len(map)):
                    pickle.dump(sim, f)
        print(f"pickled sims from {tag} (took {timer.wall_time_elapsed})")
    except:
        if outpath.exists():
            outpath.unlink()
Ejemplo n.º 6
0
def test_loaded_map_is_same_object_as_previously_created_map():
    map = htmap.map(lambda x: x, range(1), tag='singleton')

    recovered = htmap.load('singleton')

    assert recovered is map
Ejemplo n.º 7
0
def test_load_on_bad_tag_raises_tag_not_found():
    with pytest.raises(htmap.exceptions.TagNotFound):
        htmap.load('no-such-tag')
Ejemplo n.º 8
0
def test_load_shortcut(mapped_doubler):
    result = mapped_doubler.map(range(3), tag='load-shortcut')

    loaded = htmap.load('load-shortcut')

    assert loaded is result
Ejemplo n.º 9
0
def test_can_be_recovered_after_retag(mapped_doubler):
    m = mapped_doubler.map(range(1), tag='old')

    m.retag('new')

    htmap.load('new')
Ejemplo n.º 10
0
import htmap as ht

if __name__ == "__main__":
    future = ht.load("test-1")

    for result in future:
        print(result)
Ejemplo n.º 11
0
def test_can_be_recovered_after_retag(mapped_doubler):
    m = mapped_doubler.map(range(1), tag="old")

    m.retag("new")

    htmap.load("new")