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

noisy warning: Flag "[name]" accessed without a request, which is likely in the context of a celery task. #320

Open
Tracked by #32888
DanielVZ96 opened this issue Oct 24, 2023 · 5 comments
Assignees
Labels
blocked by other work PR cannot be finished until other work is complete enhancement Relates to new features or improvements to existing features

Comments

@DanielVZ96
Copy link

DanielVZ96 commented Oct 24, 2023

This warning is appearing 29 times during provisioning in the edx-platform repo. It clutters logs and hinders dev experience (openedx/edx-platform#32888).

@regisb does this still need to be a warning? I'm trying to figure if I should ignore it in the edx-platform logs, or even if it should be moved to info/debug here.

Specific line of the warning: https://github.com/openedx/edx-toggles/blob/b93431d/edx_toggles/toggles/internal/waffle/flag.py#L79-L83

@DanielVZ96 DanielVZ96 changed the title Noisy warning: Flag "[name]" accessed without a request, which is likely in the context of a celery task. noisy warning: Flag "[name]" accessed without a request, which is likely in the context of a celery task. Oct 26, 2023
@regisb
Copy link
Contributor

regisb commented Oct 27, 2023

@regisb does this still need to be a warning?

I think it should still be a warning, but it should be deactivated in the context of provisioning.

@DanielVZ96
Copy link
Author

@regisb hmm, should we just disable all python warnings during provisioning? I think at this point any relevant warning is lost in the huge amount of logs.

cc: @Agrendalath

@regisb
Copy link
Contributor

regisb commented Nov 6, 2023

I don't think so, no. Python warnings are useful, when used correctly. They indicate deprecated packages, soon-to-be-changing APIs, etc. In general, warnings should be resolved, not muted.

In the case at hand, if it is correct behaviour to access a particular flag without a request, then the logging level should be lowered to something like INFO.

@regisb
Copy link
Contributor

regisb commented Feb 14, 2025

I'm now seeing this warning just 6 times for a single flag during provisioning (tutor local do init).

2025-02-14 09:19:19,840 WARNING 38 [edx_toggles.toggles.internal.waffle.flag] [user None] [ip None] flag.py:79 - Flag 'teams.content_groups_for_teams' accessed without a request, which

is likely in the context of a celery task.

@DanielVZ96 do you know which specific provisioning command (migrate? forum? something else?) is causing the 29 warnings?

The warning above is caused by the ./manage.py cms reindex_course command. It has the following stacktrace:

Traceback (most recent call last):
  File "/openedx/edx-platform/cms/djangoapps/contentstore/management/commands/reindex_course.py", line 148, in handle
    CoursewareSearchIndexer.do_course_reindex(store, course_key)
  File "/openedx/edx-platform/cms/djangoapps/contentstore/courseware_index.py", line 374, in do_course_reindex
    return cls._do_reindex(modulestore, course_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/cms/djangoapps/contentstore/courseware_index.py", line 384, in _do_reindex
    indexed_count = super()._do_reindex(modulestore, structure_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/cms/djangoapps/contentstore/courseware_index.py", line 282, in _do_reindex
    indexed_count = cls.index(modulestore, structure_key, timeout=180)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/cms/djangoapps/contentstore/courseware_index.py", line 251, in index                                                                                      
    groups_usage_info = cls.fetch_group_usage(modulestore, structure)                                                                                                                   
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                   
  File "/openedx/edx-platform/cms/djangoapps/contentstore/courseware_index.py", line 397, in fetch_group_usage                                                                          
    partitions_info = GroupConfiguration.get_partitions_usage_info(modulestore, structure)                                                                                              
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                              
  File "/openedx/edx-platform/cms/djangoapps/contentstore/course_group_config.py", line 236, in get_partitions_usage_info                                                               
    for block, partition_id, group_id in GroupConfiguration._iterate_items_and_group_ids(course, items):                                                                                
  File "/openedx/edx-platform/cms/djangoapps/contentstore/course_group_config.py", line 301, in _iterate_items_and_group_ids                                                            
    all_partitions = get_all_partitions_for_course(course)                                                                                                                              
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                              
  File "/openedx/edx-platform/openedx/core/lib/cache_utils.py", line 74, in decorator                                                                                                   
    result = wrapped(*args, **kwargs)                                                                                                                                                   
             ^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                   
  File "/openedx/edx-platform/xmodule/partitions/partitions_service.py", line 40, in get_all_partitions_for_course                                                                      
    all_partitions = course.user_partitions + _get_dynamic_partitions(course)                                                                                                           
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                           
  File "/openedx/edx-platform/xmodule/partitions/partitions_service.py", line 83, in _get_dynamic_partitions                                                                            
    generated_partition = generator(course)                                                                                                                                             
                          ^^^^^^^^^^^^^^^^^                                                                                                                                             
  File "/openedx/edx-platform/openedx/core/lib/teams_config.py", line 403, in create_team_set_partition                                                                                 
    if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course.id):                                                                                                                              
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                               
  File "/openedx/edx-platform/openedx/core/djangoapps/waffle_utils/__init__.py", line 122, in is_enabled                                                                                
    return super().is_enabled()                                                                                                                                                         
           ^^^^^^^^^^^^^^^^^^^^                                                                                                                                                         
  File "/mnt/edx-toggles/edx_toggles/toggles/internal/waffle/flag.py", line 34, in is_enabled                                                                                           
    return self._get_flag_active()                                                                                                                                                      
           ^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                      
  File "/mnt/edx-toggles/edx_toggles/toggles/internal/waffle/flag.py", line 59, in _get_flag_active     
    return self._get_flag_active_no_request()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This warning is caused by the CONTENT_GROUPS_FOR_TEAMS waffle flag, which is scheduled for removal in Teak. @mariajgrimaldi as the author of the original implementation, can you confirm that this flag will be removed in the next release?

@regisb regisb added the enhancement Relates to new features or improvements to existing features label Feb 14, 2025
@mariajgrimaldi
Copy link
Member

@regisb: yes, thank you! I've already scheduled the removal work. Thanks for the ping!

@regisb regisb added the blocked by other work PR cannot be finished until other work is complete label Feb 14, 2025
@mariajgrimaldi mariajgrimaldi self-assigned this Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by other work PR cannot be finished until other work is complete enhancement Relates to new features or improvements to existing features
Projects
None yet
Development

No branches or pull requests

3 participants