Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brew installed locust missing UI assets #2831

Closed
2 tasks done
rokkuci opened this issue Aug 5, 2024 · 9 comments
Closed
2 tasks done

Brew installed locust missing UI assets #2831

rokkuci opened this issue Aug 5, 2024 · 9 comments
Labels

Comments

@rokkuci
Copy link

rokkuci commented Aug 5, 2024

Prerequisites

Description

Trying to run locust web interface locally on macos, but getting this type of errors:

File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/locust/web.py", line 564, in wrapper
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/locust/web.py", line 170, in index
    return render_template("index.html", template_args=self.template_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/templating.py", line 149, in render_template
    template = app.jinja_env.get_or_select_template(template_name_or_list)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/jinja2/environment.py", line 1084, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/jinja2/environment.py", line 1013, in get_template
    return self._load_template(name, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/jinja2/environment.py", line 972, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/jinja2/loaders.py", line 126, in load
    source, filename, uptodate = self.get_source(environment, name)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/templating.py", line 65, in get_source
    return self._get_source_fast(environment, template)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/templating.py", line 99, in _get_source_fast
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: index.html

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/gevent/pywsgi.py", line 1107, in handle_one_response
    self.run_application()
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/gevent/pywsgi.py", line 1053, in run_application
    self.result = self.application(self.environ, self.start_response)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 1498, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 1476, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask_cors/extension.py", line 178, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask_cors/extension.py", line 178, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/flask/app.py", line 772, in handle_user_exception
    return self.ensure_sync(handler)(e)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/locust/2.30.0/libexec/lib/python3.12/site-packages/locust/web.py", line 155, in handle_exception
    f"UI got request for {request.path}, but it resulted in a {error.code}: {error.name}",
                                                               ^^^^^^^^^^
AttributeError: 'TemplateNotFound' object has no attribute 'code'
2024-08-05T13:49:53Z {'REMOTE_ADDR': '::ffff:127.0.0.1', 'REMOTE_PORT': '54601', 'HTTP_HOST': '0.0.0.0:8089', (hidden keys: 25)} failed with AttributeError


### Command line

locust -f locustfile.py

### Locustfile contents

```python3
from locust import HttpUser, task # type: ignore

class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("www.google.com")

Python version

3.12.4

Locust version

2.30.0

Operating system

macos 14.5

@rokkuci rokkuci added the bug label Aug 5, 2024
cyberw pushed a commit that referenced this issue Aug 5, 2024
@cyberw
Copy link
Collaborator

cyberw commented Aug 5, 2024

Can you try with 2.31.0? (should be available any minute now)

If it still doesnt work, can you give some details about how you installed locust?

@rokkuci
Copy link
Author

rokkuci commented Aug 5, 2024

thanks for quick reaction, will do tomorrow morning.

@rokkuci
Copy link
Author

rokkuci commented Aug 6, 2024

now i get this:
[2024-08-06 09:11:07,455] xxx/INFO/locust.main: Starting web interface at http://0.0.0.0:8089
[2024-08-06 09:11:07,487] xxxINFO/locust.main: Starting Locust 2.31.1
[2024-08-06 09:11:18,123] xxx/ERROR/locust.web: UI got request for /, but it resulted in a 500: index.html

and browser shows "index.html"

locustfile.py:

from locust import HttpUser, task

class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("www.google.com")

but locust import shows error: Import "locust" could not be resolvedPylancereportMissingImports

installed just by brew install locust.
have folder /locust in which locustfile.py is placed.
cd to that folder and running locust command.

using macOS.

@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2024

This due to the brew packaging, it works fine with a regular pip install locust but not via brew.

@chenrui333 are you the maintainer of the brew formula - can you have a look? Idk how brew formulas work, but the best would be to do the same as a regular pip install :)

@rokkuci
Copy link
Author

rokkuci commented Aug 6, 2024

due to some laptop restrictions i could not use pip, so would be good that this topic would not be forgotten and addressed, because we are considering to use locust in our load testing process.

@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2024

Definitely.

Have you tried pip install --user locust?

@rokkuci
Copy link
Author

rokkuci commented Aug 6, 2024

to be more specific, looks like im allowed to have pipx in my laptop, used it and it worked. Thanks for quick reactions.

@cyberw cyberw changed the title Cant start simple locustfile on macos Brew installer version UI build missing Aug 6, 2024
@cyberw cyberw changed the title Brew installer version UI build missing Brew installed locust missing UI assets Aug 6, 2024
@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2024

@mquinnfd is investigating a fix from our side.

@cyberw
Copy link
Collaborator

cyberw commented Aug 6, 2024

Should be fixed in #2839 / 2.31.2.

@cyberw cyberw closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants