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

should duplicate entries be allowed in the run sequence? #20

Open
ghost opened this issue Oct 2, 2020 · 0 comments
Open

should duplicate entries be allowed in the run sequence? #20

ghost opened this issue Oct 2, 2020 · 0 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Oct 2, 2020

when setting .sequence, the interface matches the first instance of the specified model / connection, and raises an error if a matching model / connection was already specified earlier in the passed sequence:

nemspy/nemspy/interface.py

Lines 100 to 145 in d1b45bb

@sequence.setter
def sequence(self, sequence: [str]):
sequence_entries = []
entries = {entry.sequence_entry: entry for entry in self.__sequence.sequence}
for entry in sequence:
if entry.upper() in entries:
sequence_entries.append(entries[entry.upper()])
elif '->' in entry:
models = [model.strip() for model in entry.split('->')]
if len(models) == 2:
source, destination = models
for connection in self.__sequence.connections:
if len(connection.models) == 3 and None in connection.models:
connection_source, connection_destination = [
model.model_type.value.upper()
for model in connection.models
if model is not None
]
elif len(connection.models) == 2:
connection_source, connection_destination = [
model.model_type.value.upper() for model in connection.models
]
else:
continue
if (
source == connection_source
and destination == connection_destination
):
sequence_entries.append(connection)
break
else:
raise KeyError(f'"{entry}" not in {self.connections}')
elif len(models) == 3:
for mediation in self.__sequence.mediations:
if models == [
model.model_type.value
for model in mediation.models
if model is not None
]:
sequence_entries.append(mediation)
break
else:
raise KeyError(f'"{entry}" not in {self.connections}')
else:
raise KeyError(f'"{entry}" not in {self.sequence}')
self.__sequence.sequence = sequence_entries

This is potentially a problem if the same model or connection should be used more than once, such as

OCN
OCN -> ATM
ATM
ATM -> OCN
OCN
OCN -> WAV

@saeed-moghimi-noaa is this possible?

@ghost ghost added the question Further information is requested label Oct 2, 2020
@ghost ghost changed the title interface cannot handle duplicate entries (by design) should duplicate entries be allowed in the run sequence? Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

0 participants