macunha1 / pontomaisoumenos

Intelligent punch-in scheduler with GPS coordinates oscillation and dynamic "working hours" support. Implemented for pontomais.com.br but can easily be extended to any other API
The Unlicense
9 stars 3 forks source link

Problema: ponto não está sendo marcado #5

Closed marceloavf closed 2 years ago

marceloavf commented 2 years ago

Olá @macunha1

Realizei a configuração do pontomaisoumenos em um serviço da oracle linux, porém os pontos não estão sendo marcados e não notei nenhum log anormal de erro

[opc@pontomaisoumenos pontomaisoumenos]$ docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS
           NAMES
df7e3bcaf14c        opc/pontomaisoumenos:latest   "dramatiq app.tasks"     23 hours ago        Up 23 hours
           pontomaisoumenos_dramatiq_1
ef653504441b        postgres:11.1                 "docker-entrypoint.s…"   23 hours ago        Up 23 hours         0.0.0.0:35432->5432/tcp   pontomaisoumenos_postgresql_1
93159bf1b190        redis:5.0-alpine3.8           "docker-entrypoint.s…"   23 hours ago        Up 23 hours         0.0.0.0:36379->6379/tcp   pontomaisoumenos_redis_1
[opc@pontomaisoumenos pontomaisoumenos]$ docker logs df7e3bcaf14c
[2021-12-01 11:49:20,985] [PID 1] [MainThread] [dramatiq.MainProcess] [INFO] Dramatiq '1.8.1' is booting up.
Setting up metrics...
Setting up metrics...
Loading modules...
Loading modules...
Sending forks to main process...
Starting worker threads...
Starting worker threads...
Adding consumer for queue 'default'.
Adding consumer for queue 'default'.
Running consumer thread...
Running consumer thread...
Adding consumer for delay queue 'default.DQ'.
Adding consumer for delay queue 'default.DQ'.
Running consumer thread...
Running worker thread...
Running consumer thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Worker process is ready for action.
Running worker thread...
Running worker thread...
Running worker thread...
Running worker thread...
Worker process is ready for action.

Saberia o que pode estar acontecendo?

Agradeço,

marceloavf commented 2 years ago

Consegui o log no container que caiu

[opc@pontomaisoumenos pontomaisoumenos]$ docker logs 152dbf167cbf
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
[opc@pontomaisoumenos pontomaisoumenos]$
marceloavf commented 2 years ago

Estou limpando o docker e iniciando novamente pelo make RUN_MIGRATIONS=yes dev Pelo que observei, as migrations não rodaram

marceloavf commented 2 years ago

Agora o make não está rodando 🤡

...
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:692:16: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:801:37: F821 undefined name 'basestring'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:805:32: F821 undefined name 'file'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:806:38: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:818:32: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:824:32: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:832:36: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:836:23: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:837:21: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/ssl_match_hostname/_implementation.py:81:15: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/ssl_.py:32:9: E741 ambiguous variable name 'l'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/url.py:207:38: E203 whitespace before ':'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/url.py:235:27: E203 whitespace before ':'
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:19:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:48:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:61:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:324:1: E266 too many leading '#' for block comment
make: *** [tests] Error 1
macunha1 commented 2 years ago

Olá @marceloavf!

Agora o make não está rodando clown_face

...
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:692:16: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:801:37: F821 undefined name 'basestring'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:805:32: F821 undefined name 'file'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:806:38: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:818:32: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:824:32: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:832:36: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:836:23: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/six.py:837:21: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/packages/ssl_match_hostname/_implementation.py:81:15: F821 undefined name 'unicode'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/ssl_.py:32:9: E741 ambiguous variable name 'l'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/url.py:207:38: E203 whitespace before ':'
./venv/lib/python3.8/site-packages/pip/_vendor/urllib3/util/url.py:235:27: E203 whitespace before ':'
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:19:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:48:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:61:1: E266 too many leading '#' for block comment
./venv/lib/python3.8/site-packages/pip/_vendor/webencodings/x_user_defined.py:324:1: E266 too many leading '#' for block comment
make: *** [tests] Error 1

Pela versão do Python e o prefixo do virtual env, isso parece ser o docker-compose falhando.

marceloavf commented 2 years ago

@macunha1 estou instalando o python 3.7 referente ao usado no docker-compose e depois vou atualiza-lo também

Pelo que percebi o Oracle linux vem com algumas libs faltando, necessitando uma instalação manual

Uma dúvida que fiquei no sistema, ele marca apenas 2 pontos por dia ou são 4 pontos com saída e entrada do almoço?

Obrigado!

macunha1 commented 2 years ago

Consegui o log no container que caiu

[opc@pontomaisoumenos pontomaisoumenos]$ docker logs 152dbf167cbf
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 150, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 141, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 111, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 101, in generate_monthly_working_hours
    return save_punches(simulator=PunchSimulator(**configuration),
TypeError: __init__() got an unexpected keyword argument 'user'
[opc@pontomaisoumenos pontomaisoumenos]$

Esse erro foi introduzido quando atualizei a versão do pandas e eu não tinha percebido até agora :see_no_evil:

Obrigado por reportar, vou fazer push de alguns fixes pra master, antes de reiniciar o seu scheduler roda um git pull no repo.

Uma dúvida que fiquei no sistema, ele marca apenas 2 pontos por dia ou são 4 pontos com saída e entrada do almoço?

Sim, são dois pontos por dia. Na empresa que eu trabalhava eles descontavam uma hora de almoço automaticamente e eu acabei não implementando essa parte. Se você se interessar e implementar essa feature eu agradeceria, está realmente faltando

marceloavf commented 2 years ago

Testando com o código novo tive esse problema:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 148, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 139, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 109, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 100, in generate_monthly_working_hours
    return save_punches(simulator=punch_simulator, user=user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 47, in save_punches
    for punch_at in simulator.generate():
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 134, in generate
    available_business_days=business_days)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 124, in generate_punches
    raise Exception("Reached the limit of retries without success."
Exception: Reached the limit of retries without success.Try to tune your configurations
macunha1 commented 2 years ago

Testando com o código novo tive esse problema:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 148, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 139, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 109, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 100, in generate_monthly_working_hours
    return save_punches(simulator=punch_simulator, user=user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 47, in save_punches
    for punch_at in simulator.generate():
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 134, in generate
    available_business_days=business_days)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 124, in generate_punches
    raise Exception("Reached the limit of retries without success."
Exception: Reached the limit of retries without success.Try to tune your configurations

Esse erro é o que está no README https://github.com/macunha1/pontomaisoumenos#erros-conhecidos.

Normalmente acontece quando o algoritmo genético não conseguiu achar nem uma geração válida. Você precisa ajustar os valores nas configurações para conseguir atinguir uma quantidade de horas que chegue no esperado, dentro das configurações.

Por exemplo: aumentar o máximo de horas por dia, diminuir a variação.

Se ajustar esses valores não funcionar, me passa suas configurações para working_hours para eu tentar reproduzir o mesmo erro.

[working_hours]
possible_minutes_variation_start = 0
possible_minutes_variation_end = 59
# The hour that you (wanna) start to work
possible_start_hour = 9
lunch_time = 1
# If you have flexible journey, this variable
# will define the variation in the start hour
# Otherwise, set it as 1 and it'll use the exact
# time defined at "possible_start_hour"
accepted_start_hour_variation = 1.23
maximum_daily_working_hours = 10
expected_daily_hours = 8.8
marceloavf commented 2 years ago

Deixei assim as configs:

[working_hours]
possible_minutes_variation_start = 0
possible_minutes_variation_end = 59
# The hour that you (wanna) start to work
possible_start_hour = 8
lunch_time = 0
# If you have flexible journey, this variable
# will define the variation in the start hour
# Otherwise, set it as 1 and it'll use the exact
# time defined at "possible_start_hour"
accepted_start_hour_variation = 1.23
maximum_daily_working_hours = 10
expected_daily_hours = 8
macunha1 commented 2 years ago

Deixei assim as configs:

[working_hours]
possible_minutes_variation_start = 0
possible_minutes_variation_end = 59
# The hour that you (wanna) start to work
possible_start_hour = 8
lunch_time = 0
# If you have flexible journey, this variable
# will define the variation in the start hour
# Otherwise, set it as 1 and it'll use the exact
# time defined at "possible_start_hour"
accepted_start_hour_variation = 1.23
maximum_daily_working_hours = 10
expected_daily_hours = 8

Não consegui reproduzir, com esses parâmetros (usando a branch master) o container está gerando os pontos:

2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-03T10:23:00
Enqueueing message 'd29ae69b-055d-498d-b8f6-368aea008321' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-03T20:25:00
Enqueueing message 'ea518a9a-2a97-43a8-9ddf-20878c39b64b' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-06T10:04:00
Enqueueing message 'f8237e01-4863-4af9-990b-396e2b3b8333' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-06T18:03:00
Enqueueing message '56d715fc-8d4e-4dff-9dc4-88bc28da7c0b' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-07T09:27:00
Enqueueing message '86298e39-d472-4147-96fd-0bf57d4ac218' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-07T20:15:00
Enqueueing message 'd8e7295a-49dd-4c19-8585-a20f89729b35' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-08T10:57:00
Enqueueing message '43798d72-31a9-4b9c-8aa3-d35a6543b661' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-08T18:10:00
Enqueueing message '682c1de3-596f-4a2c-999b-21a04cabc42e' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-09T10:07:00
Enqueueing message '13eebe56-9354-4fce-8f09-551de6f1abbc' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-09T19:38:00
Enqueueing message '82b7c804-d937-41c3-8034-9cd1cc325cd2' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-10T10:13:00
Enqueueing message 'b362918a-1fcf-4b8f-92e6-1feb0f5a0710' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-10T20:44:00
Enqueueing message '9a35b126-a375-417c-8e79-fb1c9ff016f0' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-13T09:09:00
Enqueueing message 'a6ff28de-97ac-41f3-855c-79da127b175e' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-13T20:14:00
Enqueueing message '2a7e2b0c-66b7-4462-ac82-81430cddd787' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-14T09:32:00
Enqueueing message '3a56ad99-ae0d-4691-8549-39fdd5a206ca' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-14T20:26:00
Enqueueing message 'a3d2e643-9693-426c-b461-bf60cc685411' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-15T10:37:00
Enqueueing message '1d577ef1-724a-4867-80ef-470361c11784' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-15T19:15:00
Enqueueing message 'ed78d3a4-f5ae-47f6-8271-2f4d8f5b6f27' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-16T09:13:00
Enqueueing message 'd953b605-f419-4d54-a799-fbdabc9dd26c' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-16T18:19:00
Enqueueing message '9e306c4d-8fd8-479a-83ba-ed99d4eb446a' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-17T09:49:00
Enqueueing message '9a9d5431-e774-410f-9410-5dcfa48c653c' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-17T20:51:00
Enqueueing message '53afef16-bf48-4417-9f4c-96d6f24d9fc8' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-20T09:27:00
Enqueueing message '2c3230f6-a981-423b-8649-5b0938249ed8' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-20T20:27:00
Enqueueing message '96fce75a-e624-49cb-afad-0e8197ab06ce' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-21T10:11:00
Enqueueing message 'd1ba64c0-62ac-46f1-8192-43add8257c6b' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-21T20:05:00
Enqueueing message 'fb1d8a49-036c-4039-8975-8a10feed5fb5' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-22T09:00:00
Enqueueing message '1a27870e-3211-4f36-a225-dc4a353770fb' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-22T20:05:00
Enqueueing message '8043dac5-a501-477f-8c4b-fb8f1bd7ee94' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-23T10:26:00
Enqueueing message 'f7c3bea1-2474-4fa9-b249-d0f399bc4676' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-23T20:25:00
Enqueueing message '5af137bf-428e-43bb-a74f-d747633ebc08' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-24T09:27:00
Enqueueing message '188b8797-5e24-4db4-8905-1acce6ff4de1' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-24T19:51:00
Enqueueing message 'ca492c66-c47e-472c-b9ec-68ad16186325' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-27T10:05:00
Enqueueing message 'b329af53-727d-4244-a07c-613255a03bb2' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-27T18:19:00
Enqueueing message '67b9caa4-a553-44ca-95fa-92600067dc17' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-28T09:10:00
Enqueueing message '2d9f195a-8426-4060-aefe-5b9a4097f0ec' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-28T18:16:00
Enqueueing message '2c21513e-8bb6-429a-9dcf-6d6f303e3aef' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-29T09:14:00
Enqueueing message '6a64f551-b843-4dae-ba79-3a4e27015fee' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-29T20:38:00
Enqueueing message '8187b161-eed6-4edf-bee9-aa6d4a55d4a7' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-30T09:10:00
Enqueueing message '02606538-8d02-4e59-9f5f-e3278483d2ee' on queue 'default.DQ'.
2522c745-71e1-4a4c-8ea0-6ac56f08b969 scheduled to punch at 2021-12-30T19:04:00
Enqueueing message '20eee0f4-2847-47a8-b78d-5ada01952549' on queue 'default.DQ'.

Eu clonei o repositório, destrui os containers da versão anterior com docker-compose down, e recomecei com make RUN_MIGRATIONS=yes dev. (esse comando no make deve atualizar a imagem também).

marceloavf commented 2 years ago

Limpei a execução do docker, image e volumes, mas continua o mesmo problema

Pode ser algo na máquina, estou usando um serviço da Oracle com Oracle Linux 7

macunha1 commented 2 years ago

@marceloavf o timezone na máquina está configurado para o mesmo em que você trabalha?

Vale a pena tentar diminuir o valor em accepted_start_hour_variation também para ter mais opções e possivelmente chegar em uma válida.

accepted_start_hour_variation = 1.08
marceloavf commented 2 years ago

@macunha1 coloquei o timezone igual ao especificado no docker e desliguei a variação adicionando o valor = 1 e recebi o seguinte log:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 148, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 139, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 109, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 100, in generate_monthly_working_hours
    return save_punches(simulator=punch_simulator, user=user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 47, in save_punches
    for punch_at in simulator.generate():
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 134, in generate
    available_business_days=business_days)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 111, in generate_punches
    from_datetime=business_day)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 80, in get_possible_datetime
    hour=numpy.random.choice(possible_hours),
  File "mtrand.pyx", line 1126, in mtrand.RandomState.choice
ValueError: a must be non-empty
macunha1 commented 2 years ago

Obrigado por pegar mais um bug @marceloavf (:

Quando os dois valores (inicio+fim) são iguais (porque não tem variação) numpy.arange retorna uma lista vazia. Se ao invés disso a array só tem um número, todas as gerações dão mais tempo do que o máximo esperado (e.g. total no mínimo 200, sendo que deveria somar no máximo 176).

Vou fazer push de um fix pra master. Faz mais um pull e vê se funciona dessa vez

marceloavf commented 2 years ago

Voltou pro outro erro, tentei reduzir a jornada e aumentar o limite do algoritmo, mas não sai desse problema 😞

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 148, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 139, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 109, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 100, in generate_monthly_working_hours
    return save_punches(simulator=punch_simulator, user=user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 47, in save_punches
    for punch_at in simulator.generate():
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 141, in generate
    available_business_days=business_days)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 130, in generate_punches
    raise Exception("Reached the limit of retries without success."
Exception: Reached the limit of retries without success.Try to tune your configurations
macunha1 commented 2 years ago

Voltou pro outro erro, tentei reduzir a jornada e aumentar o limite do algoritmo, mas não sai desse problema disappointed

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 148, in <module>
    main()
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 139, in main
    schedule_punches(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 109, in schedule_punches
    .all() or generate_monthly_working_hours(user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 100, in generate_monthly_working_hours
    return save_punches(simulator=punch_simulator, user=user)
  File "/usr/local/lib/pontomaisoumenos/app/main.py", line 47, in save_punches
    for punch_at in simulator.generate():
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 141, in generate
    available_business_days=business_days)
  File "/usr/local/lib/pontomaisoumenos/app/punches.py", line 130, in generate_punches
    raise Exception("Reached the limit of retries without success."
Exception: Reached the limit of retries without success.Try to tune your configurations

A variação no começo da jornada é configurável (pelo config/default.toml), mas a do fim é calculada usando as horas esperadas e o máximo de horas por dia:

https://github.com/macunha1/pontomaisoumenos/blob/7376b1ea16466708cf1fc3d365ce28079255affb/app/punches.py#L47-L49

Tenta ajustar o maximum_daily_working_hours para não gerar números muitos dispersos, isso deve manter o algoritmo próximo das 176 horas esperadas no mês.

Se você preferir eu acabei de fazer um push com uma configuração para usar o valor que chegar mais perto da carga horária esperada:

[algorithm]
enable_best_effort = true
marceloavf commented 2 years ago

Obrigadow!