Skip to content

Make migrations scripts#483

Merged
haneslinger merged 3 commits intodevelop-v2from
Add-migration-scripts
Aug 30, 2023
Merged

Make migrations scripts#483
haneslinger merged 3 commits intodevelop-v2from
Add-migration-scripts

Conversation

@haneslinger
Copy link
Copy Markdown
Contributor

Cute little script to modified BuildingSync files from 2.4 to 2.5

Copy link
Copy Markdown
Contributor

@ThibaultMarzullo ThibaultMarzullo left a comment

Choose a reason for hiding this comment

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

This looks good, thank you! On top of the comments that I made throughout the files, can you also include one file for testing? If we do not have an example XML with the right fields, maybe you can amend a minimalist XML like this L000 pre-simulation XML.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add an example of usage please?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!


def update_usefulLife(tree):
for usefulLife in tree.findall('.//*{http://buildingsync.net/schemas/bedes-auc/2019}UsefulLife'):
usefulLife.text = usefulLife.text.split(".", 1)[0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
usefulLife.text = usefulLife.text.split(".", 1)[0]
usefulLife.text = str(int(usefulLife.text))

Currently, we only round down, is this right? If so, would this also round up when necessary?

exit(f"File could not be read \n{e} \naborting...")

update_usefulLife(tree)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you log or at least display the instances in which the script changed the number that the user had input in the original XML? For example, if usefulLife was 3.4, it would become 3 after this script updates the field. If we change that number, it would be worth pointing it out to the user to avoid surprises.


update_usefulLife(tree)

tree.write(file_path)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you save the original file under a different name like ye_olde_excemelle or a sober and more appropriate suffix like my_xml_old?

@haneslinger haneslinger added the Schema: No Changes No updates to the BuildingSync Schema label Aug 28, 2023
@haneslinger
Copy link
Copy Markdown
Contributor Author

This looks good, thank you! On top of the comments that I made throughout the files, can you also include one file for testing? If we do not have an example XML with the right fields, maybe you can amend a minimalist XML like this L000 pre-simulation XML.

There are mutliple v2.4 files in the repo currently, for example, docs/notebooks/bsync_examples/example-smalloffice-level2.xml (UsefulLife on L1408). Are you looking for something more specific?

@JieXiong9119
Copy link
Copy Markdown
Contributor

This one looks good, but I want to point out that we had something built for version converting by using xsl in here. I'm not sure if xsl is something more generic for xml conversion and might be useful for future development.

@haneslinger
Copy link
Copy Markdown
Contributor Author

oh, this would have been great to know about. I haven't worked with xsl, let me dig into it.

@haneslinger
Copy link
Copy Markdown
Contributor Author

haneslinger commented Aug 28, 2023

wait, these scripts are for v2 to v3 and it's on develop-v3. Can you give me some context: what happened to v3?

@JieXiong9119
Copy link
Copy Markdown
Contributor

wait, these scripts are for v2 to v3, what happened to v3?

v3 is a frozen version that was determined not to be released in the near future. I don't think you want to dig into xslt - I suggest we go with pure Python but refer to that v3 xslt tool for the extensibility of this script (e.g. adding a comment note like the one in v3 converter such as "This BuildingSync v2.5 document was generated from a BuildingSync v2.4 document via ....").

Copy link
Copy Markdown
Contributor

@ThibaultMarzullo ThibaultMarzullo left a comment

Choose a reason for hiding this comment

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

This is looking good, thanks Hannah!
I like Jie's suggestion of adding a comment saying that an XML was converted from 2.4 to 2.5 with this script.

@haneslinger
Copy link
Copy Markdown
Contributor Author

I want to be clear: You want a comment in the generated/updated xml file stating it was modified by the script?

@JieXiong9119
Copy link
Copy Markdown
Contributor

I want to be clear: You want a comment in the generated/updated xml file stating it was modified by the script?

Yes. Something like this line in the xslt tool for v2-to-v3, which adds a comment on top of the generated xml.

Copy link
Copy Markdown
Contributor

@JieXiong9119 JieXiong9119 left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you Hannah!

@haneslinger haneslinger merged commit 615cde7 into develop-v2 Aug 30, 2023
@haneslinger haneslinger deleted the Add-migration-scripts branch August 30, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Non-breaking Change Schema: No Changes No updates to the BuildingSync Schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants