geeksforsocialchange / imok

A simple bot to support people doing risky activities
https://gfsc.studio/blog/2021/imok-is-launched/
MIT License
12 stars 1 forks source link

Development instructions not working after upgrade #15

Closed kimadactyl closed 3 years ago

kimadactyl commented 3 years ago

It would be nice if this was all a lot cleaner. Is there a way to alias the commands somehow within the app?

$ docker-compose run web python manage.py behave --simple
Starting imok_db_1 ... done
Creating imok_web_run ... done
Creating test database for alias 'default'...
Exception ModuleNotFoundError: No module named 'freezegun'
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/behave_django/management/commands/behave.py", line 150, in handle
    exit_status = behave_main(args=behave_args)
  File "/usr/local/lib/python3.7/site-packages/behave/__main__.py", line 183, in main
    return run_behave(config)
  File "/usr/local/lib/python3.7/site-packages/behave/__main__.py", line 127, in run_behave
    failed = runner.run()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 804, in run
    return self.run_with_paths()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 809, in run_with_paths
    self.load_step_definitions()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 796, in load_step_definitions
    load_step_modules(step_paths)
  File "/usr/local/lib/python3.7/site-packages/behave/runner_util.py", line 412, in load_step_modules
    exec_file(os.path.join(path, name), step_module_globals)
  File "/usr/local/lib/python3.7/site-packages/behave/runner_util.py", line 386, in exec_file
    exec(code, globals_, locals_)
  File "features/steps/alarm_steps.py", line 5, in <module>
    from freezegun import freeze_time
ModuleNotFoundError: No module named 'freezegun'
$ docker-compose run web python manage.py migrate
Starting imok_db_1 ... done
Creating imok_web_run ... done
Operations to perform:
  Apply all migrations: admin, application, auth, contenttypes, sessions
Running migrations:
  Applying application.0004_member_is_ok... OK
$ docker-compose run web python manage.py behave --simple
Creating imok_web_run ... done
Creating test database for alias 'default'...
Got an error creating the test database: database "test_postgres" already exists

Type 'yes' if you would like to try deleting the test database 'test_postgres', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Exception ModuleNotFoundError: No module named 'freezegun'
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/behave_django/management/commands/behave.py", line 150, in handle
    exit_status = behave_main(args=behave_args)
  File "/usr/local/lib/python3.7/site-packages/behave/__main__.py", line 183, in main
    return run_behave(config)
  File "/usr/local/lib/python3.7/site-packages/behave/__main__.py", line 127, in run_behave
    failed = runner.run()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 804, in run
    return self.run_with_paths()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 809, in run_with_paths
    self.load_step_definitions()
  File "/usr/local/lib/python3.7/site-packages/behave/runner.py", line 796, in load_step_definitions
    load_step_modules(step_paths)
  File "/usr/local/lib/python3.7/site-packages/behave/runner_util.py", line 412, in load_step_modules
    exec_file(os.path.join(path, name), step_module_globals)
  File "/usr/local/lib/python3.7/site-packages/behave/runner_util.py", line 386, in exec_file
    exec(code, globals_, locals_)
  File "features/steps/alarm_steps.py", line 5, in <module>
    from freezegun import freeze_time
ModuleNotFoundError: No module named 'freezegun'
wheresalice commented 3 years ago

Freezegun was added to provide time-based testing. You will need to run docker-compose build whenever the requirements.txt file has changed. It's pretty cheap to run this after pulling any updated code because it will only do anything if requirements.txt has changed.

We could create a Makefile for running these commands, but I'm not sure that will simplify things by much.

kimadactyl commented 3 years ago

I think a Makefile would be good as there's commands in a few different files -- be really nice to have them all in one place. I've not really used docker compose or python and they look super unintuitive, been spoilt by how it works in rails :)