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

support parameters to be string represenations of complex types #37

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

romeokienzler
Copy link
Collaborator

for terratorch config is passed in as yaml config, therefore we need to be able to go from string to complex type

for terratorch config is passed in as yaml config, therefore we need to be able to go from string to complex type
Copy link
Collaborator

@WillTrojak WillTrojak left a comment

Choose a reason for hiding this comment

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

I think this is a bit dodgey. You are saying that any string that is passed to the model as these inputs should be evaluated, this can allow malicious code execution. What would probably be better would be to use numpy fromstring, depending on what you're trying to do.

if isinstance(static_input_scalers_mu, str): static_input_scalers_mu = eval(static_input_scalers_mu)
if isinstance(static_input_scalers_sigma, str): static_input_scalers_sigma = eval(static_input_scalers_sigma)
if isinstance(output_scalers, str): output_scalers = eval(output_scalers)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove new line.

@@ -803,6 +803,14 @@ def __init__(
"""
super().__init__()

# assume input_scalers_mu is string of form: torch.tensor([0] * 1280)
if isinstance(input_scalers_mu, str): input_scalers_mu = eval(input_scalers_mu)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about these evals.

@WillTrojak
Copy link
Collaborator

@romeokienzler, any update on this? Also, can you roll back the changes force pushed to main.

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.

2 participants