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

fix(engine): update workflow paths and output handling in feature transformer #593

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

miseyu
Copy link
Contributor

@miseyu miseyu commented Oct 24, 2024

Overview

What I've done

What I haven't done

How I tested

Screenshot

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features

    • Updated dependency versions for several nusamai packages, enhancing functionality.
    • Introduced a new AttributeFlattener action in the workflow for improved attribute processing.
  • Bug Fixes

    • Enhanced entity processing logic with stricter type checks to filter out non-feature objects.
  • Documentation

    • Updated descriptions for processors in the schema, clarifying their purposes and functionalities.
    • Updated workflow configurations for quality checks, improving clarity and consistency in attribute handling.
  • Chores

    • Adjusted FEATURE_FLUSH_THRESHOLD to optimize feature processing within the runtime environment.

@miseyu miseyu self-assigned this Oct 24, 2024
@miseyu miseyu requested a review from a team as a code owner October 24, 2024 07:18
Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Warning

Rate limit exceeded

@miseyu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 60b7341 and 4171c71.

Walkthrough

This pull request includes updates to the Cargo.toml file for a Rust workspace, specifically changing the version tags for several nusamai project dependencies from v0.3.1 to v0.4.0. Additionally, it modifies several files related to attribute processing and workflow configuration, including restructuring classes and methods in attribute_flattener.rs, enhancing entity processing in citygml.rs, and adjusting workflow definitions in various YAML files. The changes focus on improving attribute handling and workflow configurations without altering the overall logic or control flow.

Changes

File Path Change Summary
engine/Cargo.toml Updated versions for dependencies: nusamai-citygml, nusamai-gltf, nusamai-mvt, nusamai-plateau, nusamai-projection from v0.3.1 to v0.4.0.
engine/runtime/action-plateau-processor/src/attribute_flattener.rs Restructured Flattener and CommonAttributeProcessor classes; added FLATTEN_PREFIXES; updated methods for attribute processing.
engine/runtime/action-processor/src/feature/reader/citygml.rs Enhanced parse_tree_reader function with new type checks for entity processing.
engine/runtime/examples/plateau/example_feature_transformer.rs Changed argument in main function from "data-convert/04-luse-lsld/workflow.yml" to "data-convert/01-bldg/workflow.yml".
engine/runtime/examples/plateau/testdata/workflow/attribute_flatterner.yml Deleted workflow configuration for PLATEAU.AttributeFlattener.
engine/runtime/examples/plateau/testdata/workflow/data-convert/01-bldg/workflow.yml Added new action node AttributeFlattener and updated connections in the workflow.
engine/runtime/examples/plateau/testdata/workflow/quality-check/05-luse-urf/workflow.yml Updated output paths and changed valueAttribute to expr in several actions.
engine/runtime/runner/src/orchestrator.rs Modified FEATURE_FLUSH_THRESHOLD from 256 to 512.
engine/schema/actions.json Updated descriptions for PLATEAU.AttributeFlattener and PLATEAU.BuildingUsageAttributeValidator processors.

Possibly related PRs

🐰 "In the meadow where we play,
Versions change, and workflows sway.
Attributes flatten, new paths we find,
With every hop, we leave old behind.
A dance of code, so bright and neat,
In our burrow, we celebrate this feat!" 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for reearth-flow canceled.

Name Link
🔨 Latest commit 4171c71
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/6719f6d909a1ad0008928e33

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
engine/runtime/examples/plateau/testdata/workflow/data-convert/01-bldg/workflow.yml (1)

64-68: Consider adding documentation for the AttributeFlattener node.

To improve maintainability, consider adding a comment explaining:

  • The purpose of attribute flattening in this workflow
  • The expected input and output data structure
  • Any specific transformation rules being applied
+      # Flattens complex CityGML attributes into a simplified structure
+      # Input: CityGML feature attributes
+      # Output: Flattened attribute structure
       - id: 1bd42875-4b8c-4439-82dc-9554d9946b07
         name: AttributeFlattener
         type: action
         action: PLATEAU.AttributeFlattener
engine/runtime/action-processor/src/feature/reader/citygml.rs (3)

178-183: LGTM! Consider adding debug logging for skipped entities.

The added type checks improve the robustness of the code by properly filtering out non-feature objects. This is a good defensive programming practice.

Consider adding debug logging when entities are skipped to help with troubleshooting:

 let nusamai_citygml::Value::Object(obj) = &ent.root else {
+    log::debug!("Skipping non-object entity: {:?}", ent.root);
     continue;
 };
 let nusamai_citygml::object::ObjectStereotype::Feature { .. } = &obj.stereotype else {
+    log::debug!("Skipping non-feature object: {:?}", obj.stereotype);
     continue;
 };

Line range hint 156-159: Consider documenting the coordinate transformation.

The in-place coordinate swapping (lat,lng -> lng,lat) is a critical operation that could benefit from a more detailed comment explaining why this transformation is necessary and what coordinate system we're converting from/to.

 geom_store.vertices.iter_mut().for_each(|v| {
-    // Swap x and y (lat, lng -> lng, lat)
+    // Transform coordinates from CityGML's (lat, lng, height) to GeoJSON's (lng, lat, height) format
+    // This is necessary because CityGML uses a different coordinate order than most geospatial formats
     (v[0], v[1], v[2]) = (v[1], v[0], v[2]);
 });

Line range hint 184-187: Consider using structured error types.

The current error handling uses string formatting which makes it harder to handle specific error cases programmatically. Consider creating specific error variants for different failure modes.

Example enhancement:

#[derive(Debug)]
pub enum CityGmlError {
    GeometryConversionError(String),
    InvalidFeatureError(String),
    // ... other specific error types
}

// Then use it like:
let geometry: Geometry = ent.try_into().map_err(|e| 
    super::errors::FeatureProcessorError::FileCityGmlReader(
        CityGmlError::GeometryConversionError(e.to_string())
    )
)?;
engine/runtime/examples/plateau/testdata/workflow/quality-check/05-luse-urf/workflow.yml (1)

188-201: LGTM: Attribute mapping expressions are standardized

The attribute mapping expressions now consistently use env.get("__value") for accessing values, making the code more explicit and maintainable.

Consider extracting common attribute mapping patterns into reusable templates or helper functions to reduce code duplication. For example:

# Define common mappers in a separate config
common_mappers:
  - attribute: Index
    expr: env.get("__value").fileIndex
  - attribute: Folder
    expr: env.get("__value").udxDirs
  # ... other common mappers

# Reference in nodes
nodes:
  - name: AttributeMapperInvalidSurface
    type: action
    action: AttributeMapper
    with:
      mappers: !include common_mappers

This would make the workflow more maintainable and reduce the risk of inconsistencies between similar mapper configurations.

engine/runtime/action-plateau-processor/src/attribute_flattener.rs (1)

Line range hint 234-238: Potential Panic Due to Unchecked unwrap()

At line 236, area_type_code_count.unwrap() is called without checking if it is Some. If area_type_code_count is None, this will cause a panic at runtime. It's important to handle the None case to avoid unexpected panics.

Apply this diff to safely handle the None case:

-if desc.is_none() || area_type_code.is_none() || area_type_code_count.unwrap() > 2 {
+if desc.is_none() || area_type_code.is_none() || area_type_code_count.map_or(false, |count| count > 2) {

This change ensures that if area_type_code_count is None, the condition gracefully handles it without panicking.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 005f304 and 819181b.

⛔ Files ignored due to path filters (1)
  • engine/Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (8)
  • engine/Cargo.toml (1 hunks)
  • engine/runtime/action-plateau-processor/src/attribute_flattener.rs (8 hunks)
  • engine/runtime/action-processor/src/feature/reader/citygml.rs (1 hunks)
  • engine/runtime/examples/plateau/example_feature_transformer.rs (1 hunks)
  • engine/runtime/examples/plateau/testdata/workflow/attribute_flatterner.yml (0 hunks)
  • engine/runtime/examples/plateau/testdata/workflow/data-convert/01-bldg/workflow.yml (2 hunks)
  • engine/runtime/examples/plateau/testdata/workflow/quality-check/05-luse-urf/workflow.yml (3 hunks)
  • engine/runtime/runner/src/orchestrator.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • engine/runtime/examples/plateau/testdata/workflow/attribute_flatterner.yml
✅ Files skipped from review due to trivial changes (2)
  • engine/runtime/examples/plateau/example_feature_transformer.rs
  • engine/runtime/runner/src/orchestrator.rs
🔇 Additional comments (12)
engine/runtime/examples/plateau/testdata/workflow/data-convert/01-bldg/workflow.yml (2)

122-126: LGTM! Edge configurations are properly defined.

The new edges correctly integrate the AttributeFlattener node into the workflow, maintaining proper data flow between FeatureReader and VerticalReprojector nodes.


64-68: Verify if the AttributeFlattener node requires configuration parameters.

The node definition appears to be missing a with section for configuration. Other action nodes in this workflow include configuration parameters, and the related Rust changes mention FLATTEN_PREFIXES. Consider whether any parameters should be exposed here.

✅ Verification successful

Let me search for the AttributeFlattener implementation to understand if it requires any configuration parameters.


Based on the Rust implementation, I can now provide a definitive response:

The AttributeFlattener node configuration is correctly defined

The node definition in the workflow.yml is complete and correct as is. Looking at the Rust implementation:

  1. The parameter_schema method explicitly returns None, indicating this processor doesn't accept any configuration parameters
  2. The processor is designed to work with default settings, automatically flattening CityGML attributes for building features
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other AttributeFlattener configurations in the codebase
rg -t yaml "action: PLATEAU.AttributeFlattener" -A 10

Length of output: 1303


Script:

#!/bin/bash
# Search for AttributeFlattener implementation in Rust files
rg -t rust "AttributeFlattener" -A 10

Length of output: 9002

engine/Cargo.toml (1)

64-68: Verify the impact of breaking changes in nusamai dependencies.

The update from v0.3.1 to v0.4.0 represents a breaking change according to semver. The changes appear coordinated with updates in attribute processing and workflow configurations.

Let's verify the changes:

✅ Verification successful

Let me gather more information about potential breaking changes by checking for any modifications in the usage of these dependencies.


Based on the gathered information, I can now provide a final response:

Breaking changes in nusamai v0.4.0 have been properly handled

The update from v0.3.1 to v0.4.0 has been consistently applied across all nusamai dependencies, and the codebase shows proper integration:

  • All nusamai dependencies are consistently using v0.4.0
  • The v0.3.1 references found are unrelated (in go.sum for different packages)
  • Usage patterns show proper imports and integration across multiple components:
    • Geometry handling (types, projections, transformations)
    • CityGML processing
    • MVT (Map Vector Tiles) functionality
    • Coordinate system operations

Recent commits also show a history of coordinated nusamai dependency updates, indicating this is part of a planned upgrade process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all nusamai dependencies are consistently updated and check for any remaining v0.3.1 references

# Test 1: Check for any remaining v0.3.1 references
echo "Checking for any remaining v0.3.1 references..."
rg "v0.3.1"

# Test 2: Verify that all nusamai dependencies are at v0.4.0
echo "Verifying nusamai dependency versions..."
rg 'nusamai-[a-z]+.*tag = "v[0-9]+\.[0-9]+\.[0-9]+"'

Length of output: 1260


Script:

#!/bin/bash
# Check for any changes in the usage of nusamai dependencies
echo "Checking for changes in nusamai usage patterns..."
rg -A 2 "use nusamai_" --type rust

# Check git history for related changes
echo -e "\nChecking recent commits for nusamai-related changes..."
git log --grep="nusamai" --since="1 month ago" --pretty=format:"%h %s"

# Look for potential breaking changes in error handling or type signatures
echo -e "\nChecking for potential breaking changes in function calls..."
ast-grep --pattern 'nusamai_$_::$_($$$)'

Length of output: 12433

engine/runtime/examples/plateau/testdata/workflow/quality-check/05-luse-urf/workflow.yml (1)

179-179: LGTM: Output path construction is simplified and consistent

The output path construction for error reporting files has been standardized using file::join_path, making it more maintainable and consistent across the workflow.

Also applies to: 216-216

engine/runtime/action-plateau-processor/src/attribute_flattener.rs (8)

Line range hint 468-488: Ensure Correct Handling of Risk Attributes for Building Features

The implementation correctly extends flattened with various risk attributes when ftype.as_str() == "bldg:Building". Ensure that all necessary risk attribute extraction methods are called and that they handle the attributes appropriately.


283-312: Recursive Flattening in flatten_attribute Function

The flatten_attribute function efficiently handles recursive flattening of nested attributes. The use of recursion and conditional checks ensures that attributes are flattened correctly based on their structure.


551-556: Extending Feature Attributes with New CityGML Attributes

In lines 551-556, the code extends feature.attributes with new_city_gml_attribute. The mapping from String keys to Attribute is correctly handled, and the attributes are properly cloned.


581-585: Proper Use of Unused Parameters in finish Method

The finish method correctly includes unused parameters _ctx and _fw, prefixed with underscores to indicate intentional non-use. This follows Rust conventions and prevents compiler warnings.


564-574: Efficient Removal of Unnecessary Attributes

The loop from lines 564-574 efficiently removes attributes that are not needed. The conditions check for specific prefixes and suffixes to identify attributes to remove.


19-90: Initialization of FLATTEN_PREFIXES

The static FLATTEN_PREFIXES is initialized using Lazy and correctly populates the HashSet with all necessary attribute prefixes. The use of vec! and iteration ensures that both keys and combined keys are included.


135-135: ⚠️ Potential issue

Redundant .get Call on the Same Key

In line 135, the .get("uro:rank") is called twice in the or_else chain. This redundancy does not serve any purpose and might be a copy-paste error. Consider removing the redundant call or replacing it with the intended key.

Apply this diff to correct the redundancy:

-let rank = risk_map
-    .get("uro:rank")
-    .or_else(|| risk_map.get("uro:rank"));
+let rank = risk_map.get("uro:rank");

Or, if a different key was intended:

-let rank = risk_map
-    .get("uro:rank")
-    .or_else(|| risk_map.get("uro:rank"));
+let rank = risk_map
+    .get("uro:rank")
+    .or_else(|| risk_map.get("uro:rankOrg"));

Likely invalid or redundant comment.


338-340: ⚠️ Potential issue

Handle Possible None Value When Unwrapping num_lod

In the update_max_lod method, unwrapping num_lod.as_i64().unwrap() without checking if as_i64() returns Some can lead to a panic if it returns None. To ensure robustness, handle the None case appropriately.

Apply this diff to prevent potential panic:

-if num_lod.as_i64().unwrap() > 0 {
+if let Some(num_lod_i64) = num_lod.as_i64() {
+    if num_lod_i64 > 0 {
         if self.max_lod < lod {
             self.max_lod = lod;
         }
         if gml_max_lod < lod {
             gml_max_lod = lod;
             self.gml_path_to_max_lod
                 .insert(gml_path.clone(), gml_max_lod);
         }
+    }
+}

This modification checks if num_lod.as_i64() returns Some before unwrapping, ensuring safe execution.

Likely invalid or redundant comment.

@miseyu miseyu merged commit f12cbf7 into main Oct 24, 2024
15 checks passed
@miseyu miseyu deleted the feature/modify-attribute-flatten branch October 24, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant