8000 Simplify xmi to liquid by kwkwan · Pull Request #136 · lutaml/lutaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Simplify xmi to liquid #136

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

Merged
merged 4 commits into from
Mar 5, 2025
Merged

Simplify xmi to liquid #136

merged 4 commits into from
Mar 5, 2025

Conversation

kwkwan
Copy link
Contributor
@kwkwan kwkwan commented Feb 27, 2025

No description provided.

@kwkwan kwkwan linked an issue Feb 27, 2025 that may be closed by this pull request
@@ -16,7 +16,7 @@
end

it "correctly reads schema attributes" do
expect(parse.schemas.first.id).to(eq('annotated_3d_model_data_quality_criteria_schema'))
expect(parse.schemas.first.id).to(eq("annotated_3d_model_data_quality_criteria_schema"))
Copy link

Choose a reason for hiding this comment

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

Line is too long. [96/80]

# @param link [Lutaml::Model::Serializable]
# @param link_member_name [String]
# @return [Array<String, String, Hash, String, String>]
def serialize_member_type(owner_xmi_id, link, link_member_name)
Copy link

Choose a reason for hiding this comment

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

Method has too many lines. [11/10]

10000

# @param general_id [String]
# @return [Array<Hash>]
def get_general_hash(general_id)
Copy link

Choose a reason for hiding this comment

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

Method has too many lines. [15/10]

return nil
end
end
def initialize
Copy link

Choose a reason for hiding this comment

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

Call super to initialize state of the parent class.

module Lutaml
module SysMl
class ConstraintBlock < Block
def initialize
Copy link

Choose a reason for hiding this comment

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

Call super to initialize state of the parent class.

def initialize
@property_path = []
end
def initialize
Copy link

Choose a reason for hiding this comment

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

Call super to initialize state of the parent class.

end

if (["uml:Property", "uml:Port"].include?(xml_node.attribute_with_ns("type",
xmiNS.href).to_s)) && not ["definingFeature", "partWithPort", "propertyPath",
Copy link

Choose a reason for hiding this comment

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

unexpected token tLBRACK

path_to_file = File.join(include_root,
path_to_file)
end
File.read(path_to_file).split("\n").map do |line|
Copy link

Choose a reason for hiding this comment

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

Shadowing outer local variable - line.

@kwkwan
Copy link
Contributor Author
kwkwan commented Feb 27, 2025

Hi @ronaldtse,

Please do not merge this PR at this moment as I found some strange performance problem and bugs.

For performance problem, the time for running all lutaml specs is about 3m47s, which is 8m16s before. So, it seems faster.

HOWEVER, if I run the specs of metanorma-plugin-lutaml with the NEW lutaml, it takes 48m. if I run the specs of metanorma-plugin-lutaml with the OLD lutaml, it takes 20m. It is slower than before.

Moreover, when I ran the specs of metanorma-plugin-lutaml even with the OLD lutaml, some Liquid render error: Liquid error: internal were occurred, which were not occurred at the previous time when I ran the specs. As I ran bundle update before running the specs, I thought some underlying gems causing these errors.

@ronaldtse
Copy link
Contributor

For NEW and OLD lutaml, can you determine versions they are?

This will be helpful for @HassanAkbar in profiling/debugging. Thanks!

8000

@kwkwan
Copy link
Contributor Author
kwkwan commented Feb 27, 2025

For NEW and OLD lutaml, can you determine versions they are?

This will be helpful for @HassanAkbar in profiling/debugging. Thanks!

OLD lutaml means v0.9.28.

NEW lutaml means the changes in the branch simplify-xmi-to-liquid.

@ronaldtse
Copy link
Contributor

HOWEVER, if I run the specs of metanorma-plugin-lutaml with the NEW lutaml, it takes 48m. if I run the specs of metanorma-plugin-lutaml with the OLD lutaml, it takes 20m. It is slower than before.

Moreover, when I ran the specs of metanorma-plugin-lutaml even with the OLD lutaml, some Liquid render error: Liquid error: internal were occurred, which were not occurred at the previous time when I ran the specs. As I ran bundle update before running the specs, I thought some underlying gems causing these errors.

Actually, it's possible that the metanorma-plugin-lutaml specs are running faster with OLD lutaml because there are Liquid errors leading to some skipped code. If the current lutaml implementation passes all specs, I prefer to merge first and then address any performance issues after. Correctness is more important.

@kwkwan
Copy link
Contributor Author
kwkwan commented Feb 27, 2025

I found the area in lutaml that causes the Liquid internal error. Let me add some fixes first.

def initialize(model) # rubocop:disable Lint/MissingSuper
@model = model
end

def min
@model[:min]
return @model[:min] if @model.is_a?(Hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for compatibility with the old approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is not for compatibility.

def initialize(model) # rubocop:disable Lint/MissingSuper
@model = model
end

def name
@model[:name]
HTMLEntities.new.decode(@model.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move this to the xmi gem?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kwkwan can we move this to the xmi gem?

# @param with_absolute_path: [Boolean]
# @return [Hash]
# @note xpath: //uml:Model[@xmi:type="uml:Model"]
def serialize_to_hash(xmi_model,
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice!!

Copy link
Contributor
@ronaldtse ronaldtse left a comment

Choose a reason for hiding this comment

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

Just a few questions.

@kwkwan
Copy link
Contributor Author
kwkwan commented Feb 27, 2025

HOWEVER, if I run the specs of metanorma-plugin-lutaml with the NEW lutaml, it takes 48m. if I run the specs of metanorma-plugin-lutaml with the OLD lutaml, it takes 20m. It is slower than before.
Moreover, when I ran the specs of metanorma-plugin-lutaml even with the OLD lutaml, some Liquid render error: Liquid error: internal were occurred, which were not occurred at the previous time when I ran the specs. As I ran bundle update be 9E88 fore running the specs, I thought some underlying gems causing these errors.

Actually, it's possible that the metanorma-plugin-lutaml specs are running faster with OLD lutaml because there are Liquid errors leading to some skipped code. If the current lutaml implementation passes all specs, I prefer to merge first and then address any performance issues after. Correctness is more important.

The bugs causing Liquid render error: Liquid error: internal have been fixed.

The performance issue still exists. The time for running specs in metanorma-plugin-lutaml with the changes in the branch simplify-xmi-to-liquid of lutaml is 48m.

@ronaldtse
Copy link
Contributor

@kwkwan can you use a ruby profiler to find out where it is being slow?

e.g. https://nipe0324.com/articles/aexymc0-53j3

@kwkwan
Copy link
Contributor Author
kwkwan commented Feb 27, 2025

@kwkwan can you use a ruby profiler to find out where it is being slow?

e.g. https://nipe0324.com/articles/aexymc0-53j3

Will have a try.

@kwkwan
Copy link
Contributor Author
kwkwan commented Mar 4, 2025

The commit bdf06fc caches the id name mapping properly. The performance has been improved. The time to run all specs in metanorma-plugin-lutaml is now 12m, which is 20m previously.

The time to run specs of lutaml becomes 3m52s, which is similar as the previous one.

@kwkwan kwkwan merged commit 7a40324 into main Mar 5, 2025
15 checks passed
@kwkwan kwkwan deleted the simplify-xmi-to-liquid branch March 7, 2025 03:36
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.

Simplify the serialization of xmi to liquid
2 participants
0