Forum Discussion
Power BI developer mode (.pbip) merge conflict issues
I'm still not aware of any solutions to this problem. Every release becomes hell and comes down to numerous merges/cherry picks flavored with manual edits.
That sounds awful.
During my research on this issue, I found this "project" to improve exactly the sorting issues we are experiencing.
I haven't checked in detail, but maybe this is relevant and might even be a viable workaround:
https://richardswinbank.net/ssas/ssas_tabular_merge_conflicts
Do let me know if this could work
- Anonymous1 year agoNot applicable
sausaged Thanks a lot for sharing this! In essence model.bim turned out to be a json file, so we can actually play around with its content just as with report.json. I took the idea you shared as a basis and wrote my own simple Python code that sorts the contents of all nested structures, just because it's easier for us to maintain it in Python rather than with shell. We've been testing this approach for a couple of weeks now and I must say that now if conflicts do arise, they are intuitive and resolved in the code editor, so thank you again.
- sausaged1 year agoFrequent Visitor
Anonymous That's great to hear. Are you able to share a working version of this python script? This might be helpful for many users!
- Anonymous1 year agoNot applicable
sausaged Sure. Below is the version that works for us so far:
import json import sys def process(obj): """ Recursively sorts lists containing dictionaries with the 'name' attribute by the 'name' key, and strips trailing \r from string values. """ if isinstance(obj, list): # If all elements are dictionaries with a 'name' key, sort them if all(isinstance(item, dict) and 'name' in item for item in obj): # Sort the list of dictionaries by the 'name' key and recursively process each item in the list return sorted([process(item) for item in obj], key=lambda x: x['name']) else: # Recursively process each item in the list return [process(item) for item in obj] elif isinstance(obj, dict): # Recursively process each value in the dictionary return {key: process(value) for key, value in obj.items()} elif isinstance(obj, str): # Strip trailing \r from strings return obj.rstrip('\r') else: return obj def main(): # Check if filename is provided as command-line argument if len(sys.argv) < 2: print("Usage: python reorder_content.py <file_name>") sys.exit(1) # Get filename from command-line argument file_name = sys.argv[1] try: with open(file_name, 'r') as file: content = json.load(file) processed_content = process(content) with open(file_name, 'w') as file: json.dump(processed_content, file, indent=4) print(f"Processed {file_name}") except FileNotFoundError: print(f"File not found: {file_name}") except json.JSONDecodeError: print(f"Error decoding JSON in file: {file_name}") if __name__ == '__main__': main()The script should be located at `.\pre-commit\reorder-content.py` and triggered by `.\.git\hooks\pre-commit` content of which is as follows:
#!/bin/bash FILE="./[Project Name].SemanticModel/model.bim" python.exe ./pre-commit/reorder-content.py "$FILE" git add "$FILE"Don't forget to substitute [Project Name] respectively in the pre-commit script.