Hi, I have very basic question, but it just doesn'...
# ask-community
m
Hi, I have very basic question, but it just doesn't make sense to me so I must be missing something. I used prefect 1 and I LOVED it! One of my favorite features was that I didn't need to build DAG myself - prefect could identify dependencies between tasks itself and figure out what can be called in parallel. I haven't touched prefect for 2 years and I missed this feature in the other tool I used. I was excited to get back to prefect 2, but here is what I don't understand - it is not supported anymore out of the box? And I tried to use ConcurrentTaskRunner but somehow it is not enough and I need to do something else? Code in the thread for clarity - but this is also conceptual question - why remove such powerful feature?
Copy code
import httpx
from prefect import flow, task
import time
from prefect.task_runners import ConcurrentTaskRunner


@task(retries=2)
def get_repo_info(repo_owner: str, repo_name: str, delay: 20):
    """Get info about a repo - will retry twice after failing"""
    url = f"<https://api.github.com/repos/{repo_owner}/{repo_name}>"
    api_response = httpx.get(url)
    api_response.raise_for_status()
    repo_info = api_response.json()

    time.sleep(delay)
    return repo_info


@task
def get_contributors(repo_info: dict):
    """Get contributors for a repo"""
    contributors_url = repo_info["contributors_url"]
    response = httpx.get(contributors_url)
    response.raise_for_status()
    contributors = response.json()
    return contributors


@flow(log_prints=True, task_runner=ConcurrentTaskRunner)
def repo_info(repo_owner: str = "PrefectHQ", repo_name: str = "prefect"):

    # I want 1 and 2 to execute concurrently
    repo_info_1 = get_repo_info(repo_owner, repo_name, 60)
    repo_info_2 = get_repo_info(repo_owner, repo_name, 10)
    print(f"Stars 🌠 : {repo_info_2['stargazers_count']}")

    contributors = get_contributors(repo_info_2)
    print(f"Number of contributors 👷: {len(contributors)}")


if __name__ == "__main__":
    repo_info()
this is an adjusted code from quickstart, where there is no downstream dependency on repo_info_1 so i expect it to be in parallel with repo_info_2 (however it is not) - something that worked in prefect 1 out of the box
Ok I found it - I was missing .submit so issue is now resolved. But I still hope to understand this change in approach 🤞