Coder Social home page Coder Social logo

Comments (11)

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

to run MSNoise, my current idea is either to execute steps like this

(1.1) $ python -m msnoise --step 1
or
(1.2) $ python -m msnoise.s01scan_archive

or create a msnoise in Python/Scripts and

(2) $ msnoise --step 1

any suggestions ?

I remember reading some comment advocating for the first solution (written by someone fed up with the /scripts folder being super full)... But with the first (1.1) solution, it's not really easy to pass arguments to step 1...

from msnoise.

krischer avatar krischer commented on June 12, 2024

The first version is nice for commands that are rarely called by users (e.g. tests, benchmarks, ...).

MSNoise on the other hand really focuses on actually using these commands so it is completely justified in my opinion to have a central msnoise script that can (after installation) be called from everywhere.

Then you can design a git like interface (main command followed by the subcommand followed by the arguments), e.g.

$ msnoise scan_archive .
$ msnoise do_other_stuff --who=me /path/to/stuff

That is what I did here: http://lasif.net/cli.html (the documentation is actually autogenerated from the code with the help of a custom sphinx directive). My favorite part turned out to be the testing. A custom pytest fixture (https://github.com/krischer/LASIF/blob/5ad0ff11abe7703c3a9ae4507374389dee4e194f/lasif/tests/testing_helpers.py#L69-106) is used to make it really easy and clean to test the command line interface, e.g. https://github.com/krischer/LASIF/blob/5ad0ff11abe7703c3a9ae4507374389dee4e194f/lasif/tests/test_cli_interface.py#L108-L115

I coded the command dispatching and all the other stuff by hand: It is fairly straightforward to implement some nice features like fuzzy subcommand matching and pretty help messages. But nowadays I would just use something like this: http://click.pocoo.org

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

Mmmm Thanks ! That sound reallllly cool : http://click.pocoo.org/3/quickstart/#nesting-commands

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

Ok, so far so good, using Click

[test1] C:\Users\tlecocq\Desktop>msnoise
Usage: msnoise-script.py [OPTIONS] COMMAND [ARGS]...

Options:
  -t, --threads INTEGER  Nulmber of threads to use
  --help                 Show this message and exit.

Commands:
  bugreport
  config
  install
  scan_archive
[test1] C:\Users\tlecocq\Desktop>msnoise bugreport --help
Usage: msnoise-script.py bugreport [OPTIONS]

Options:
  -s, --sys      System Info
  -m, --modules  Modules Info
  -e, --env      Environment Info
  -a, --all      All Info
  --help         Show this message and exit.

Cooooool :-)

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024
[test1] C:\Users\tlecocq\Desktop\tmprun>msnoise
Usage: msnoise-script.py [OPTIONS] COMMAND [ARGS]...

Options:
  -t, --threads INTEGER  Number of threads to use (only affects modules that
                         are designed to do parallel processing)
  --help                 Show this message and exit.

Commands:
  bugreport     This command launches the Bug Report script.
  compute_cc    Computes the CC jobs (based on the "New Jobs"...
  compute_dtt   Computes the dt/t jobs based on the new MWCS...
  compute_mwcs  Computes the MWCS based on the new stacked...
  config        This command launches the Configurator.
  install       This command launches the installer.
  new_jobs      Determines if new CC jobs are to be defined
  plot          Top level command to trigger different plots
  populate      Rapidly scan the archive filenames and find...
  reset         Resets the job to "T"odo.
  scan_archive  Scan the archive and insert into the Data...
  stack         Stacks the [REF] and/or [MOV] windows

almost done :-)

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

f945ba2 marks the first big (read -HUGE-) step toward packaging MSNoise !

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

I think this can be considered done...

from msnoise.

krischer avatar krischer commented on June 12, 2024

I don't think this is really done TBH. For example the dependencies are not specified in the setup.py and I am also not sure it installs everything it needs. A good test is always to install (without --develop or -e) to a clean virtual environment that only contains numpy and see if everything still works and if the tests can somehow be executed.

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

aaah that... is correct :-)

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

and at some point, when that looks ready, learn how to make a PyPi upload... :s

from msnoise.

ThomasLecocq avatar ThomasLecocq commented on June 12, 2024

I think it's OK...

from msnoise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.