Skip to content

Fix SWE L1b: prevent None propagation when no full science cycles found#2806

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/fix-swe-l1b-local-error
Draft

Fix SWE L1b: prevent None propagation when no full science cycles found#2806
Copilot wants to merge 2 commits intodevfrom
copilot/fix-swe-l1b-local-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

When all incoming science packets are in-flight calibration data (esa_table_num != 0), swe_l1b_science returns None (no complete 4-quarter cycles). swe_l1b was unconditionally appending this None to processed_datasets, causing downstream failures in post-processing.

Changes

  • swe/l1b/swe_l1b.py: Guard the append in swe_l1b with a None check:

    # Before
    science_dataset = swe_l1b_science(dependencies)
    processed_datasets.append(science_dataset)  # silently appends None
    
    # After
    science_dataset = swe_l1b_science(dependencies)
    if science_dataset is not None:
        processed_datasets.append(science_dataset)
  • tests/swe/test_swe_l1b.py: Add test_swe_l1b_no_full_cycles — mocks swe_l1b_science returning None and asserts the returned dataset list contains no None entries.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.dev.imap-mission.com
    • Triggering command: /usr/bin/python python -m pytest imap_processing/tests/swe/test_swe_l1b.py::test_swe_l1b_no_full_cycles -v (dns block)
    • Triggering command: /usr/bin/python python -m pytest imap_processing/tests/swe/test_swe_l1b.py::test_get_full_cycle_data_indices imap_processing/tests/swe/test_swe_l1b.py::test_count_rate imap_processing/tests/swe/test_swe_l1b.py::test_get_checker_board_pattern -v -m (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>SWE L1b failure</issue_title>
<issue_description>In the latest SWE l1b job, there is an unbound local error during processing.

Processing SWE l1b
Traceback (most recent call last):
  File "/usr/local/bin/imap_cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 1523, in main
    instrument.process()
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 444, in process
    products = self.do_processing(dependencies)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 1378, in do_processing
    datasets = swe_l1b(dependencies)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/swe/l1b/swe_l1b.py", line 954, in swe_l1b
    science_dataset = swe_l1b_science(dependencies)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/swe/l1b/swe_l1b.py", line 739, in swe_l1b_science
    full_cycle_l1a_data, checkerboard_pattern
    ^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'full_cycle_l1a_data' where it is not associated with a value
```</issue_description>

<agent_instructions>Processing SWE l1b
Traceback (most recent call last):
  File "/usr/local/bin/imap_cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 1523, in main
    instrument.process()
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 444, in process
    products = self.do_processing(dependencies)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/cli.py", line 1378, in do_processing
    datasets = swe_l1b(dependencies)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/swe/l1b/swe_l1b.py", line 954, in swe_l1b
    science_dataset = swe_l1b_science(dependencies)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/imap_processing/swe/l1b/swe_l1b.py", line 739, in swe_l1b_science
    full_cycle_l1a_data, checkerboard_pattern
    ^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'full_cycle_l1a_data' where it is not associated with a value</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

When all science data is in-flight calibration data (esa_table_num != 0),
swe_l1b_science returns None due to the early return for no full cycles.
The calling swe_l1b function was unconditionally appending this None to
processed_datasets, causing failures in post-processing.

Add a None check before appending to prevent propagation of None downstream.

Co-authored-by: tech3371 <36522642+tech3371@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unbound local error in SWE L1b processing Fix SWE L1b: prevent None propagation when no full science cycles found Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SWE L1b failure

2 participants