Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bcc2761 authored Feb 5, 2024
1 parent 90c411b commit 94b5135
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ FMS Runtime Environment (FRE) CLI developed using Python's Click package
- Create new Conda environment
- `conda create -n [environmentName]`
- Run `conda install` on needed dependencies
- `conda install noaa-gfdl::fre-cli` should install the CLI package located at https://anaconda.org/NOAA-GFDL/fre-cli created from the meta.yaml file
- `conda install noaa-gfdl::fre-cli` should install the CLI package located at https://anaconda.org/NOAA-GFDL/fre-cli created from the `meta.yaml` file
- All other dependencies used by the tools are installed along with this install (configured inside the meta.yaml), with the exception of local modules
- setup.py file allows `fre.py` to be ran with `fre` as the entry point in the command line instead of `python fre.py`
- setup.py file allows `fre.py` to be ran with `fre` as the entry point on the command line instead of `python fre.py`
* Enter commands and follow `--help` messages for guidance (brief rundown of commands also provided below)
- If the user just runs `fre`, it will list all the command groups following `fre`, such as `run`, `make`, `pp`, etc. and once the user specifies a command group, the list of available subcommands for that group will be shown
- Commands that require arguments to run will alert user about missing arguments, and will also list the rest of the optional parameters if `--help` is executed
Expand Down Expand Up @@ -42,12 +42,12 @@ In development:
- Example: `fre catalog buildCatalog -i /archive/am5/am5/am5f3b1r0/c96L65_am5f3b1r0_pdclim1850F/gfdl.ncrc5-deploy-prod-openmp/pp -o ~/output --overwrite`

To be developed:
1) **fre check**
2) **fre list**
3) **fre make**
4) **fre run**
5) **fre test**
6) **fre yamltools**
1. **fre check**
2. **fre list**
3. **fre make**
4. **fre run**
5. **fre test**
6. **fre yamltools**

## **Usage (Developers)**

Expand All @@ -56,8 +56,32 @@ To be developed:
- Once inside the repository, developers can test local changes by running a `pip install .` inside of the root directory to install the fre-cli package locally with the newest local changes
- Test as a normal user would use the CLI

### **Adding New Tools - Checklist**

If there is *no* subdirectory created for the new tool you are trying to develop, there are a few steps to follow:

1. Create a subdirectory for the tool group inside the /fre folder; i.e. /fre/newTool
2. Add an `__init__.py` inside of the new subdirectory
- this will contain one line, `from fre.subTool import *`
- the purpose of this line is to allow the subTool module to include all the scripts and functions within it when invoked by `fre`
3. Add a file named `fre(subTool).py`. This will serve as the main file to house all of the tool's related subcommands
4. Add a Click group named after the subTool within `fre(subTool).py`
- This group will contain all of the subcommands
5. Create separate files to house the code for each different subcommand; *do not* code out the full implemetation of a function inside of a Click command within `fre(subTool).py`
6. Be sure to import the contents of the needed subcommand scripts inside of `fre(subTool).py`
- i.e. `from fre.subTool.subCommandScript import *`
7. At this point, you can copy and paste the parts of your main Click subcommand from its script into `fre(subTool).py` when implementing the function reflective of the subcommand function
- Everything will remain the same; i.e. arguments, options, etc.
- However, this new function within `fre(subTool).py` must a new line after the arguments, options, and other command components; `@click.pass_context`
- Along with this, a new argument "context" must now be added to the parameters of the command (preferably at the beginning, but it won't break it if it's not)
8. From here, all that needs to be added after defining the command with a name is `context.forward(mainFunctionOfSubcommand)`, and done!
9. After this step, it is important to add `from fre.subTool import *` to the `__init__.py` within the /fre folder
10. The last step is to replicate the subcommand in the same way as done in `fre(subTool).py` inside of `fre.py`, but make sure to add `from fre import subTool` and `from fre.subTool.fre(subTool) import * `

### **Adding Tools From Other Repositories**

* Currently, the solution to this task is to approach it using Conda packages. The tool that is being added must reside within a repository that contains a meta.yaml that includes Conda dependencies like the one in this repository and ideally a setup.py (may be subject to change due to deprecation) that may include any potentially needed pip dependencies
- Once published as a Conda package, ideally on the NOAA-GFDL channel at https://anaconda.org/NOAA-GFDL, an addition can be made to the "run" section under the "requirements" category in the meta.yaml of the fre-cli following the syntax `channel:package`
- On pushes to the main branch, the package located at https://anaconda.org/NOAA-GFDL/fre-cli will automatically be updated using the workflow file

### **Example Directory Structure**

0 comments on commit 94b5135

Please sign in to comment.