示例#1
0
 def upload_pkg(cls, sdist: Path, dp_cfg: DatapaneCfg,
                **kwargs) -> "Script":
     # TODO - use DPTmpFile
     # merge all the params for the API-call
     kwargs["api_version"] = __version__
     new_kwargs = {**dp_cfg.to_dict(), **kwargs}
     return cls.post_with_files(file=sdist, **new_kwargs)
示例#2
0
def test_run_bundle(rc, datadir: Path, monkeypatch, capsys):
    monkeypatch.chdir(datadir)
    # monkeypatch.setenv("DATAPANE_ON_DATAPANE", "true")
    monkeypatch.setenv("DATAPANE_BY_DATAPANE", "true")

    # TODO - we should prob use a pre-built sdist here...
    dp_config = DatapaneCfg.create_initial(
        config_file=Path("dp_test_mod.yaml"))
    with build_bundle(dp_config) as sdist:
        # whl_file = build_bundle(dp_config, sdist, shared_datadir, username="******", version=1)
        try:
            # NOTE - need to pass in all params as we're not setting defaults via dp-server
            res = _runner({
                "p1": "VAL",
                "p2": "xyz",
                "p3": True
            },
                          dp_config.script,
                          sdist=sdist)
        finally:
            subprocess.run(
                [sys.executable, "-m", "pip", "uninstall", "--yes", "pytil"],
                check=True)
    # asserts
    (out, err) = capsys.readouterr()
    assert "ran script" in out
    assert "p2=xyz" in out
    assert "WORLD" in out
    assert dp.Result.get() == "hello , world!"
    assert res.report_id is None
示例#3
0
def gen_build_cfg() -> DatapaneCfg:
    return DatapaneCfg(
        name="my_foo_module",
        script=Path("foo.py"),
        requirements=["requests >=2.6"],
        include=["bar.py", "config.yaml", "model.bin", "sub_pkg/"],
        exclude=["README.md", ".gitignore", "sub_pkg/ignore_me.py"],
    )
示例#4
0
 def load_defaults(self, config_fn: NPath = DATAPANE_YAML) -> None:
     if not by_datapane:
         log.debug(f"loading parameter defaults from {config_fn}")
         # TODO - move dp-server parameter handling into common to use runnerconfig.format
         # NOTE - this is a bit hacky as we don't do any type formatting
         cfg = DatapaneCfg.create_initial(config_file=Path(config_fn))
         defaults = {p["name"]: p["default"] for p in cfg.parameters if "default" in p}
         self.update(defaults)
     else:
         log.debug("Ignoring call to load_defaults as by datapane")