<#962 Use TailLogs defined in dataproxy> Pull requ...
# flyte-github
a
#962 Use TailLogs defined in dataproxy Pull request opened by katrogan 1. Added tail_logs to ClusterAwareDataProxy (returns an AsyncIterator synchronously, matching the protocol) 2. SelectCluster: added a new _resolve_by_action cached resolver. Extracted the SelectCluster + client construction into a shared _select_and_build helper that both resolvers call. Testing Ran the demo cluster locally. Tested with flyte-sdk and this script
Copy code
@env.task
async def spew_logs(duration_sec: int = 300, interval_sec: int = 5) -> str:
    elapsed = 0
    iteration = 0
    while elapsed < duration_sec:
        iteration += 1
        print(f"[{elapsed:>4}s] iteration {iteration} - still running...", flush=True)
        await asyncio.sleep(interval_sec)
        elapsed += interval_sec
    print(f"Done after {elapsed}s ({iteration} iterations)", flush=True)
    return f"completed {iteration} iterations"


if __name__ == "__main__":
    import sys

    config_path = sys.argv[1] if len(sys.argv) > 1 else None
    if config_path:
        from flyte.config import Config

        flyte.init_from_config(Config.auto(config_path))
    else:
        flyte.init_from_config()
    run = flyte.run(spew_logs)
    print(f"Run: {run.name}")
    print(f"URL: {run.url}")
    print("Tailing logs...")
    run.action.show_logs(raw=True)
Verified output worked fine
Copy code
python examples/basics/long_running.py .flyte/config-oss-local.yaml
  > Bundling code...
  ✓ Code bundle: 1 files, 0.009765625 MB (compressed 0.0006895065307617188 MB)
  > Uploading code bundle...
Run: r8xqdw87c7l266b9j99x
URL: <http://localhost:30080/v2/domain/development/project/flytesnacks/runs/r8xqdw87c7l266b9j99x>
Tailing logs...
 [flyte] Flyte runtime started for action a0 with run name r8xqdw87c7l266b9j99x [   0s] iteration 1 - still running... [   5s] iteration 2 - still running... [  10s] iteration 3 - still running...
flyteorg/flyte-sdk