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

iterable parameter values not passed correctly into the command-line #171

Closed
Allycan opened this issue Aug 27, 2023 · 4 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Allycan
Copy link

Allycan commented Aug 27, 2023

There seems to be a bug with the repeat policy for a cab input that can accept two options in the form of a list to be cast as --option X --option Y on the command line.

I have defined a cab with a repeat policy of repeat: repeat as documented here but I get the output as [--option X] [--option Y].

I suggest a fix on this line to perhaps something like ' '.join(list(itertools.chain.from_iterable([option, x] for x in value))) if option else list(value). This ensures that the correct output is passed into the command-line when multiple values (in list form) for option are provided.

@o-smirnov
Copy link
Member

You mean you're literally getting [--option X] [--option Y] in the output, square brackets included? That's odd.

You can try your fix, but the join will return a single string, which will be stuffed into a single command-line argument (spaces and all), which is probably not the intention either.

@Allycan
Copy link
Author

Allycan commented Aug 28, 2023

@o-smirnov yes I get everything with the square brackets. Below is what is displayed on the terminal;

### running singularity exec /path/to/stimela_casa_1.7.0.sif   
simms --name /path/to/ms3063MHz.ms --tel meerkat --type casa --coord-sys itrf --synthesis 1.0    
--freq0 3063MHz --dfreq 1000kHz --nband 1 --nchan 5 --dtime 10 ['--direction', 'J2000,01h25m46s,-30d42m48s'] ['--direction', 'J2000,01h25m46s,-30d00m00s'] --scan-length 0.5 --scan-lag 0.0 --pol XX XY YX YY --feed perfect X Y 

I will give my suggested fix much thought and try my fix, I just thought about it from head without trying the implementation. The only problem is the square brackets and the '', so simms is not able to read the passed values.

# simms.simms.ParserError: unrecognized arguments: ['--direction', 'J2000,01h25m46s,-30d42m48s'] ['--direction', 'J2000,01h25m46s,-30d00m00s']

@o-smirnov
Copy link
Member

It's definitely a bug, but I can't see it from the code. Could you add a print statement here:

if type(value) is list:

It should be the case that type(value) is list, but from the outcome it seems that it's doing args.append(value) instead.

@Allycan
Copy link
Author

Allycan commented Aug 28, 2023

As I had thought earlier, the bug is in Line 308 of stimela/stimela/kitchen/cab.py.

Instead of using the itertools.chain(), we should be using itertools.chain.from_iterable(), just without the ' '.join() as I previously suggested.

I have changed list(itertools.chain(([option, x] for x in value))) to list(itertools.chain.from_iterable(([option, x] for x in value))) and I get the expected options parsed into the command line. See below;

### running singularity exec /path/to/stimela_casa_1.7.0.sif simms --name /path/to/ms3063MHz.ms --tel meerkat --type casa --coord-sys itrf --synthesis 1.0 --freq0 3063MHz --dfreq 1000kHz --nband 1 --nchan 5 --dtime 10 --direction J2000,01h25m46s,-30d42m48s --direction J2000,01h25m46s,-30d00m00s --scan-length 0.5 --scan-lag 0.0 --pol XX XY YX YY --feed perfect X Y

Of-course I stand to be corrected if there is anything I missed/misleading with my suggestion.

@o-smirnov o-smirnov self-assigned this Feb 13, 2024
@o-smirnov o-smirnov added the bug Something isn't working label Feb 13, 2024
@o-smirnov o-smirnov added this to the Release 2.0 milestone Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants