Giter Club home page Giter Club logo

Comments (3)

adamryczkowski avatar adamryczkowski commented on June 6, 2024

I understood, that this streaming syntax is actually the way to do:

        from hatchet_sdk import StepRunEventType
        event:StepRunEventType

        for event in self._hatchet.client.listener.stream(self._messageID):
            print(event.payload)

The problem is, that if the event does not seem to be caught if the run has already been finished before the for loop starts executing.

How do I check if the run has already been computed and get its payload? The payload is there, because it is accessible via the Web UI.

from hatchet.

adamryczkowski avatar adamryczkowski commented on June 6, 2024

One would hope to have the following code do the trick:

        from hatchet_sdk import WorkflowRun

        workflow_run:WorkflowRun = self._hatchet.client.rest_client.workflow_run_get(self._messageID)

        print(workflow_run.status)

Except, that it does not. The workflow_run_get errors with

Traceback (most recent call last):
  File "/snap/pycharm-professional/384/plugins/python/helpers-pro/pydevd_asyncio/pydevd_asyncio_utils.py", line 117, in _exec_async_code
    result = func()
             ^^^^^^
  File "<input>", line 1, in <module>
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/hatchet_sdk/clients/rest_client.py", line 58, in workflow_run_get
    return self.workflow_api.workflow_run_get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/pydantic/validate_call_decorator.py", line 58, in wrapper_function
    return validate_call_wrapper(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py", line 81, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/hatchet_sdk/clients/rest/api/workflow_api.py", line 1476, in workflow_run_get
    response_data = self.api_client.call_api(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/hatchet_sdk/clients/rest/api_client.py", line 269, in call_api
    response_data = self.rest_client.request(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/hatchet_sdk/clients/rest/rest.py", line 243, in request
    r = self.pool_manager.request(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/urllib3/_request_methods.py", line 136, in request
    return self.request_encode_url(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/urllib3/_request_methods.py", line 183, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/urllib3/poolmanager.py", line 433, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/.cache/pypoetry/virtualenvs/stan-runner-1qcHgIo7-py3.12/lib/python3.12/site-packages/urllib3/poolmanager.py", line 295, in connection_from_host
    raise LocationValueError("No host specified.")
urllib3.exceptions.LocationValueError: No host specified.

Upon inspection, the url of the underlying REST api call indeed lacks the hostname. It consists purely of the path, such as /api/v1/tenants/707d0855-80ab-4e1f-a156-f1c4546cbf52/workflow-runs/e5e3eadd-e91f-43af-a399-67c54d1aeb31.

from hatchet.

abelanger5 avatar abelanger5 commented on June 6, 2024

Hey @adamryczkowski, the empty hostname likely means that you haven't set the HATCHET_CLIENT_TOKEN environment variable. And could you share the version of the Python SDK you're using? I believe we patched the py SDK recently to fix the rest_client.

from hatchet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.