-
Notifications
You must be signed in to change notification settings - Fork 59
Drop tree.json #409
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
Drop tree.json #409
Conversation
# Conflicts: # src/web/src/views/cli/CLIModGeneratorProfileCommandTree.tsx # src/web/src/views/cli/CLIModGeneratorProfileTabs.tsx # src/web/src/views/cli/CLIModuleGenerator.tsx
Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com>
def patch_partial_items(self, aaz_command_tree: CMDSpecsCommandTree): | ||
aaz_command_tree = CMDSpecsPartialCommandTree(self.aaz_path, aaz_command_tree.root) | ||
nodes = [self.root] | ||
i = 0 | ||
while i < len(nodes): | ||
command_group = nodes[i] | ||
if isinstance(command_group, CMDSpecsCommandGroup): | ||
if isinstance(command_group.command_groups, CMDSpecsCommandGroupDict): | ||
for key in command_group.command_groups.keys(): | ||
raw_cg = command_group.command_groups.get_raw_item(key) | ||
if isinstance(raw_cg, CMDSpecsCommandGroup): | ||
nodes.append(raw_cg) | ||
elif isinstance(raw_cg, CMDSpecsPartialCommandGroup): | ||
command_group.command_groups[key] = aaz_command_tree.find_command_group(*raw_cg.names) | ||
elif isinstance(command_group.command_groups, dict): | ||
for cg in command_group.command_groups.values(): | ||
nodes.append(cg) | ||
if isinstance(command_group.commands, CMDSpecsCommandDict): | ||
for key in command_group.commands.keys(): | ||
raw_command = command_group.commands.get_raw_item(key) | ||
if isinstance(raw_command, CMDSpecsPartialCommand): | ||
command_group.commands[key] = aaz_command_tree.find_command(*raw_command.names) | ||
i += 1 | ||
|
||
def patch(self): | ||
tree_path = os.path.join(self.aaz_path, "Commands", "tree.json") | ||
if not (os.path.exists(tree_path) and os.path.isfile(tree_path)): | ||
return | ||
try: | ||
with open(tree_path, 'r', encoding="utf-8") as f: | ||
data = json.load(f) | ||
aaz_command_tree = CMDSpecsCommandTree(data) | ||
self.patch_partial_items(aaz_command_tree) | ||
except json.decoder.JSONDecodeError as e: | ||
raise ValueError(f"Invalid Command Tree file: {tree_path}") from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need those functions as we decided drop the tree.json directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest LGTM
@necusjz The {%- if command.help.lines is not none and command.help.lines|length %}
{{ command.help.lines|join('\\\n')}}
{%- endif %} |
Description
The tree.json file is growing bigger and will cause problem for git command one day. So it is required to drop tree.json file in git repo and generate it only in local cache.
The PR dropping
tree.json
in aaz model: Azure/aaz#615Backend
CMDSpecsPartialCommandTree
to support partial commands and command groups management.__getitem__
method ofCMDSpecsCommandDict
andCMDSpecsCommandGroupDict
, support similar interface of PartialCommandTree and a full CommandTree./AAZ/Specs/CommandTree/Simple
to get a simplified tree from folder structure./AAZ/Specs/CommandTree/Nodes/Leaves
to batched get command leaves.Frontend
CLIModGeneratorProfileCommandTree
. Change it from class component to function component.ModGenerator
.selected
toProfileCTCommand
andProfileCTCommandGroup
to mark selection state no matter it is loaded or not.ProfileCommandTree
to object instead of list.