Skip to content

Remove flatdict dependency by replacing fiboa-cli with lightweight parquet utilities#235

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/remove-flatdict-dependency
Closed

Remove flatdict dependency by replacing fiboa-cli with lightweight parquet utilities#235
Copilot wants to merge 4 commits intomainfrom
copilot/remove-flatdict-dependency

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

flatdict has build issues with setuptools. It's pulled in as a transitive dependency from fiboa-cli==0.7.

Changes

New module: ftw_tools/parquet_utils.py

  • features_to_dataframe(): Converts GeoJSON features to GeoDataFrame
  • create_parquet(): Writes GeoDataFrame to Parquet with fiboa metadata injection

Updated imports

  • ftw_tools/inference/utils.py
  • ftw_tools/postprocess/polygonize.py

Dependencies

  • Removed fiboa-cli==0.7 from pyproject.toml

Approach

The codebase only uses two functions from fiboa-cli: create_parquet and features_to_dataframe. Newer fiboa-cli versions (≥0.20.0) dropped flatdict but underwent a major rewrite with breaking API changes.

Rather than migrating to the incompatible API, implemented focused replacements (~80 LOC) that:

  • Use geopandas' native parquet writer for geometry serialization
  • Inject fiboa metadata via PyArrow schema metadata post-write
  • Maintain exact API compatibility with existing call sites
# Replacement implementation
def create_parquet(data, columns, collection, output_file, config=None, compression=None):
    data[columns].to_parquet(output_file, compression=compression or "zstd", index=False)
    
    table = pq.read_table(output_file)
    metadata = table.schema.metadata or {}
    metadata[b"fiboa"] = json.dumps(collection).encode("utf-8")
    pq.write_table(table.replace_schema_metadata(metadata), output_file, compression=compression)

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.lightly.ai
    • Triggering command: /home/REDACTED/work/ftw-baselines/ftw-baselines/.venv/bin/pytest pytest tests/ -k not integration and not instance_segmentation -v (dns block)
    • Triggering command: /home/REDACTED/work/ftw-baselines/ftw-baselines/.venv/bin/pytest pytest tests/ -k not integration and not instance_segmentation --ignore=tests/test_eval.py --ignore=tests/test_model_registry.py --ignore=tests/test_models.py -v (dns block)
  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)
  • data.source.coop
    • Triggering command: /home/REDACTED/work/ftw-baselines/ftw-baselines/.venv/bin/pytest pytest tests/ -k not integration and not instance_segmentation --ignore=tests/test_eval.py --ignore=tests/test_model_registry.py --ignore=tests/test_models.py -v (dns block)
  • planetarycomputer.microsoft.com
    • Triggering command: /home/REDACTED/work/ftw-baselines/ftw-baselines/.venv/bin/pytest pytest tests/ -k not integration and not instance_segmentation --ignore=tests/test_eval.py --ignore=tests/test_model_registry.py --ignore=tests/test_models.py -v (dns block)
  • sentinel-cogs.s3.us-west-2.amazonaws.com
    • Triggering command: /home/REDACTED/work/ftw-baselines/ftw-baselines/.venv/bin/pytest pytest tests/ -k not integration and not instance_segmentation --ignore=tests/test_eval.py --ignore=tests/test_model_registry.py --ignore=tests/test_models.py -v (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>Remove flatdict dependency</issue_title>
<issue_description>flatdict seems to have build issues with setup tools. We should consider removing this dependency with another convenience method.</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 13, 2026 16:37
Co-authored-by: isaaccorley <22203655+isaaccorley@users.noreply.github.com>
Co-authored-by: isaaccorley <22203655+isaaccorley@users.noreply.github.com>
…d imports

Co-authored-by: isaaccorley <22203655+isaaccorley@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove flatdict dependency due to build issues Remove flatdict dependency by replacing fiboa-cli with lightweight parquet utilities Feb 13, 2026
Copilot AI requested a review from isaaccorley February 13, 2026 16:44
@isaaccorley
Copy link
Copy Markdown
Collaborator

@copilot can we instead just upgrade the fiboa-cli which doesn't have flatdict dependency anymore?

@m-mohr
Copy link
Copy Markdown
Collaborator

m-mohr commented Feb 13, 2026

No, this doesn't work yet.
We just removed flatpack today and the ftw-baseline still uses a very old version of fiboa-cli, we need to update to the latest, but it has a lot of breaking changes. It's on my todo, but not for today. ;-)

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot can we instead just upgrade the fiboa-cli which doesn't have flatdict dependency anymore?

fiboa-cli >= 0.20.0 removed flatdict but underwent a complete rewrite that removed the create_parquet() and features_to_dataframe() functions we use. The new version is built on vecorel-cli with an incompatible object-oriented API.

Upgrading would require refactoring both call sites in ftw_tools/inference/utils.py and ftw_tools/postprocess/polygonize.py to use the new architecture.

The current lightweight implementation (~80 LOC) maintains exact API compatibility while removing the flatdict dependency. Would you prefer I refactor to use fiboa-cli 0.20.3's new API instead?

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:

  • https://api.github.com/search/issues
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

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

Copy link
Copy Markdown
Collaborator

@m-mohr m-mohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not create fiboa-compliant files anymore. fiboa CLI has some issues yet with being imported as library, so needs upstream work first.

@isaaccorley
Copy link
Copy Markdown
Collaborator

This will not create fiboa-compliant files anymore. fiboa CLI has some issues yet with being imported as library, so needs upstream work first.

Sounds good, saw the build errors in other PRs was just looking to debug but thanks for the heads up

@m-mohr
Copy link
Copy Markdown
Collaborator

m-mohr commented Feb 13, 2026

I'll try to get to it next week.

@m-mohr
Copy link
Copy Markdown
Collaborator

m-mohr commented Feb 16, 2026

Colsing in favor of #241

@m-mohr m-mohr closed this Feb 16, 2026
@m-mohr m-mohr deleted the copilot/remove-flatdict-dependency branch February 16, 2026 12:09
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.

Remove flatdict dependency

3 participants