Parsing command line options for several parameters fails

Bug #452950 reported by Johan Hake
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
High
Anders Logg

Bug Description

A user cannot send command line options to both PETSc and a user defined parameters

   ./app --petsc.foo --petsc.bar --my_foo bar

Reproduce error:
Save the following in a file parameter_fail.py

*********************************************
from dolfin import *

par = Parameters("app_par", bar="foo")

parameters.parse()
par.parse()
*********************************************

and run it from the prompt using

    python parameter_fail.py --petsc.mat_view_draw --bar=baz

Revision history for this message
Anders Logg (logg) wrote : Re: [Bug 452950] [NEW] Parsing command line options for several parameters fails

On Fri, Oct 16, 2009 at 10:11:55AM -0000, Johan Hake wrote:
> Public bug reported:
>
> A user cannot send command line options to both PETSc and a user defined
> parameters
>
> ./app --petsc.foo --petsc.bar --my_foo bar
>
> Reproduce error:
> Save the following in a file parameter_fail.py
>
> *********************************************
> from dolfin import *
>
> par = Parameters("app_par", bar="foo")
>
> parameters.parse()
> par.parse()
> *********************************************
>
> and run it from the prompt using
>
> python parameter_fail.py --petsc.mat_view_draw --bar=baz
>
> ** Affects: dolfin
> Importance: Undecided
> Status: New
>

Should we make the parse() command just parse the parameter it knows
and ignore others?

--
Anders

Revision history for this message
Johan Hake (johan-hake) wrote :

On Monday 19 October 2009 13:28:36 logg wrote:
> On Fri, Oct 16, 2009 at 10:11:55AM -0000, Johan Hake wrote:
> > Public bug reported:
> >
> > A user cannot send command line options to both PETSc and a user defined
> > parameters
> >
> > ./app --petsc.foo --petsc.bar --my_foo bar
> >
> > Reproduce error:
> > Save the following in a file parameter_fail.py
> >
> > *********************************************
> > from dolfin import *
> >
> > par = Parameters("app_par", bar="foo")
> >
> > parameters.parse()
> > par.parse()
> > *********************************************
> >
> > and run it from the prompt using
> >
> > python parameter_fail.py --petsc.mat_view_draw --bar=baz
> >
> > ** Affects: dolfin
> > Importance: Undecided
> > Status: New
>
> Should we make the parse() command just parse the parameter it knows
> and ignore others?

Good question. I have thought of this too. The nice thing with a complaining
parser is that we get notice when we type an error.

Another way is to always check for dolfin. and petsc. parameters and just
ignore them while parsing ordinary parameters, and ignore all other when
parsing the global parameters.

Not sure what's most intuitive and correct.

Johan

>
> --
> Anders
>

Revision history for this message
Anders Logg (logg) wrote :

On Mon, Oct 19, 2009 at 11:42:09AM -0000, Johan Hake wrote:
> On Monday 19 October 2009 13:28:36 logg wrote:
> > On Fri, Oct 16, 2009 at 10:11:55AM -0000, Johan Hake wrote:
> > > Public bug reported:
> > >
> > > A user cannot send command line options to both PETSc and a user defined
> > > parameters
> > >
> > > ./app --petsc.foo --petsc.bar --my_foo bar
> > >
> > > Reproduce error:
> > > Save the following in a file parameter_fail.py
> > >
> > > *********************************************
> > > from dolfin import *
> > >
> > > par = Parameters("app_par", bar="foo")
> > >
> > > parameters.parse()
> > > par.parse()
> > > *********************************************
> > >
> > > and run it from the prompt using
> > >
> > > python parameter_fail.py --petsc.mat_view_draw --bar=baz
> > >
> > > ** Affects: dolfin
> > > Importance: Undecided
> > > Status: New
> >
> > Should we make the parse() command just parse the parameter it knows
> > and ignore others?
>
> Good question. I have thought of this too. The nice thing with a complaining
> parser is that we get notice when we type an error.
>
> Another way is to always check for dolfin. and petsc. parameters and just
> ignore them while parsing ordinary parameters, and ignore all other when
> parsing the global parameters.
>
> Not sure what's most intuitive and correct.

I suggest we start with the simplest option which is to do the same
thing in both cases (not complain).

We could perhaps be verbose when we parse parameters:

  Parsing command-line parameter "foo" with value 1.0.
  Parsing command-line parameter "bar" with value "xxx".
  Passing command-line option "..." to PETSc.
  Ignoring unknown command-line option "...".

--
Anders

Revision history for this message
Johan Hake (johan-hake) wrote :

On Monday 19 October 2009 14:23:34 logg wrote:
> On Mon, Oct 19, 2009 at 11:42:09AM -0000, Johan Hake wrote:
> > On Monday 19 October 2009 13:28:36 logg wrote:
> > > On Fri, Oct 16, 2009 at 10:11:55AM -0000, Johan Hake wrote:
> > > > Public bug reported:
> > > >
> > > > A user cannot send command line options to both PETSc and a user
> > > > defined parameters
> > > >
> > > > ./app --petsc.foo --petsc.bar --my_foo bar
> > > >
> > > > Reproduce error:
> > > > Save the following in a file parameter_fail.py
> > > >
> > > > *********************************************
> > > > from dolfin import *
> > > >
> > > > par = Parameters("app_par", bar="foo")
> > > >
> > > > parameters.parse()
> > > > par.parse()
> > > > *********************************************
> > > >
> > > > and run it from the prompt using
> > > >
> > > > python parameter_fail.py --petsc.mat_view_draw --bar=baz
> > > >
> > > > ** Affects: dolfin
> > > > Importance: Undecided
> > > > Status: New
> > >
> > > Should we make the parse() command just parse the parameter it knows
> > > and ignore others?
> >
> > Good question. I have thought of this too. The nice thing with a
> > complaining parser is that we get notice when we type an error.
> >
> > Another way is to always check for dolfin. and petsc. parameters and just
> > ignore them while parsing ordinary parameters, and ignore all other when
> > parsing the global parameters.
> >
> > Not sure what's most intuitive and correct.
>
> I suggest we start with the simplest option which is to do the same
> thing in both cases (not complain).
>
> We could perhaps be verbose when we parse parameters:
>
> Parsing command-line parameter "foo" with value 1.0.
> Parsing command-line parameter "bar" with value "xxx".
> Passing command-line option "..." to PETSc.
> Ignoring unknown command-line option "...".

Agree

Johan

> --
> Anders
>

Changed in dolfin:
status: New → Confirmed
importance: Undecided → High
Changed in dolfin:
milestone: none → 0.9.12
Anders Logg (logg)
Changed in dolfin:
assignee: nobody → Anders Logg (logg)
Revision history for this message
Anders Logg (logg) wrote :

Fixed. The above test now gives

Skipping unrecognized option for parameter set "dolfin": --bar=baz
Passing options to PETSc: -mat_view_draw
Skipping unrecognized option for parameter set "app_par": --petsc.mat_view_draw

Changed in dolfin:
status: Confirmed → Fix Committed
Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 452950] Re: Parsing command line options for several parameters fails

Nice to squeeze a bug that is 1.5 year old!

Johan

On Wednesday June 1 2011 08:59:54 Anders Logg wrote:
> Fixed. The above test now gives
>
> Skipping unrecognized option for parameter set "dolfin": --bar=baz
> Passing options to PETSc: -mat_view_draw
> Skipping unrecognized option for parameter set "app_par":
> --petsc.mat_view_draw
>
>
> ** Changed in: dolfin
> Status: Confirmed => Fix Committed

Revision history for this message
Anders Logg (logg) wrote :

:-)

--
Anders

On Wed, Jun 01, 2011 at 04:18:07PM -0000, Johan Hake wrote:
> Nice to squeeze a bug that is 1.5 year old!
>
> Johan
>
> On Wednesday June 1 2011 08:59:54 Anders Logg wrote:
> > Fixed. The above test now gives
> >
> > Skipping unrecognized option for parameter set "dolfin": --bar=baz
> > Passing options to PETSc: -mat_view_draw
> > Skipping unrecognized option for parameter set "app_par":
> > --petsc.mat_view_draw
> >
> >
> > ** Changed in: dolfin
> > Status: Confirmed => Fix Committed
>

Anders Logg (logg)
Changed in dolfin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.