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

Line Breaks in String Data #568

Closed
ianboltz opened this issue Jul 9, 2021 · 9 comments · Fixed by #572
Closed

Line Breaks in String Data #568

ianboltz opened this issue Jul 9, 2021 · 9 comments · Fixed by #572
Labels

Comments

@ianboltz
Copy link

ianboltz commented Jul 9, 2021

Describe what did you try to do with TM1py
Loaded data using self.tm1.cubes.cells.write(cubename, data, use_ti=True) where the data included strings that contained line breaks.

Describe what's not working the way you expect
The TI build fails as the string data with line breaks is interpreted wrong in the TI. We need to parse any strings for line breaks (or other escape chars) before creating the TI

Version

  • TM1py [1.6.0]
  • TM1 Server Version: [2.0.9.8]
@ianboltz
Copy link
Author

ianboltz commented Jul 9, 2021

something like

attributes[(element_name, attribute)] = str(record[attribute]).replace("\n", "").replace("\r", "")

@MariusWirtz
Copy link
Collaborator

Hi @ianboltz,

Yes. I think TM1py should deal with the line breaks.

I wonder if we should by default remove all linebreaks when the use_ti is set to True or if we should add an optional argument (e.g. remove_linebreaks_for_ti) that controls if linebreaks are removed or not.

I could imagine that in some cases users would prefer a failure over a manipulated text value (no linebreaks) in the cube.

Any other opinions on this one?

@ianboltz
Copy link
Author

ianboltz commented Jul 9, 2021

I would say maybe we need two things

  • option to KEEP line breaks (so the default is to remove them),so maybe the param is keep_linebreaks_in_ti instead
  • where linebreaks are removed can we have a debug option to write to the tm1s.log with the cell address?

@MariusWirtz
Copy link
Collaborator

Yeah. We could call it keep_line_breaks_in_ti and set the default value to False.

You mean the message log right?
Until now TM1py never writes debug stuff to the TM1 logs. Don't think we should start this now. Either way, we couldn't do it consistently through the TM1py library as it requires admin permissions.

@rclapp
Copy link
Collaborator

rclapp commented Jul 9, 2021 via email

@MariusWirtz
Copy link
Collaborator

@rclapp do you mean the tm1py script should maintain its own log file and output the number of records it processes or you think tm1py should log that information into TM1's message log?

For my tm1py scripts, I always maintain a little log file next to the main.py in which I log the execution flow and relevant events to help troubleshoot and spot performance bottlenecks early on. Kinda like below:

2021-04-14 17:03:00,674 - INFO - Starting execution
2021-04-14 17:03:01,694 - INFO - Connected to source TM1 instance: 'Planing Sample' with version: '11.6.00000.14'
2021-04-14 17:03:02,011 - INFO - Successfully retrieved dimension: 'FiscalPeriod' with 50 elements from source
2021-04-14 17:03:02,151 - INFO - Successfully updated dimension: 'FiscalPeriod' in target
2021-04-14 17:03:03,770 - INFO - Successfully cleared cube 'Sales' on target instance
2021-04-14 17:03:05,211 - INFO - Attempting to process 123850 cells in total
2021-04-14 17:04:37,772 - INFO - Processed 123850 cells in total
2021-04-14 17:04:37,905 - INFO - Successfully synchronized data

For previous implementations, I only wrote to the message log in case of fatal errors that need to be brought to attention.
I think the tm1py script events or flow information would be too granular information to bring to the tm1 message log.

@rclapp
Copy link
Collaborator

rclapp commented Jul 12, 2021 via email

@MariusWirtz
Copy link
Collaborator

Update: The linebreaks only break the write with ti functionality if they are followed by a hashtag (#)

MariusWirtz added a commit that referenced this issue Jul 12, 2021
currently linebreaks followed by the hashmark (`#`) break the
`write_through_unbound_proecss` function.

since turbo integrator doesn't write linebreaks to cells anyways, we may as
well remove them from the string.

Fixes #568
@MariusWirtz
Copy link
Collaborator

@rclapp I like this idea.

Ideally, we could build something generic that is added at the top and bottom of every unbound process that's being executed by TM1py. Perhaps the logic could be added to the execute_process_with_return function?
Please feel free to open a Pull Request.

I think it makes sense to control this debugging output through an optional parameter on a TM1py function.

MariusWirtz added a commit that referenced this issue Jul 12, 2021
currently linebreaks followed by the hashmark (`#`) break the
`write_through_unbound_proecss` function.

since turbo integrator doesn't write linebreaks to cells anyways, we may as
well remove them from the string.

Fixes #568
MariusWirtz added a commit that referenced this issue Jul 13, 2021
currently linebreaks followed by the hashmark (`#`) break the
`write_through_unbound_proecss` function.

since turbo integrator doesn't write linebreaks to cells anyways, we may as
well remove them from the string.

Fixes #568
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 a pull request may close this issue.

3 participants