Skip to content

Commit

Permalink
Merge pull request #1058 from sbillinge/cmds_to_cmds
Browse files Browse the repository at this point in the history
cmds to cmds
  • Loading branch information
sbillinge authored Feb 25, 2024
2 parents 64b1d81 + a83add5 commit fd209dc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
23 changes: 23 additions & 0 deletions news/cmds_to_cmds.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* lists of commands now imported from commands.py

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
26 changes: 26 additions & 0 deletions regolith/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from regolith.helper import HELPERS, helpr, UPDATER_HELPERS, FAST_UPDATER_WHITELIST
from regolith.runcontrol import RunControl
from regolith.tools import string_types
from regolith import storage


email = emailer

Expand All @@ -21,6 +23,8 @@
INGEST_COLL_LU = {".bib": "citations"}




def add_cmd(rc):
"""Adds documents to a collection in a database."""
db = rc.client[rc.db]
Expand Down Expand Up @@ -264,3 +268,25 @@ def validate(rc):
#
# sys.exit(f"Validation failed on some records\n {cap}")
sys.exit(f"Validation failed on some records")

DISCONNECTED_COMMANDS = {
"rc": lambda rc: print(rc._pformat()),
"deploy": deploy,
"store": storage.main,
"json-to-yaml": json_to_yaml,
"yaml-to-json": yaml_to_json,
}

CONNECTED_COMMANDS = {
"add": add_cmd,
"ingest": ingest,
"app": app,
"grade": grade,
"build": build,
"email": email,
"classlist": classlist,
"validate": validate,
"helper": helper,
"fs-to-mongo": fs_to_mongo,
"mongo-to-fs": mongo_to_fs
}
14 changes: 2 additions & 12 deletions regolith/helper_gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@
from regolith.runcontrol import DEFAULT_RC, load_rcfile, filter_databases
from regolith.schemas import SCHEMAS
from regolith.tools import update_schemas
from regolith.commands import CONNECTED_COMMANDS

from gooey import Gooey, GooeyParser

CONNECTED_COMMANDS = {
"add": commands.add_cmd,
"ingest": commands.ingest,
"app": commands.app,
"grade": commands.grade,
"build": commands.build,
"email": commands.email,
"classlist": commands.classlist,
"validate": commands.validate,
"helper": commands.helper,
"fs-to-mongo": commands.fs_to_mongo
}

NEED_RC = set(CONNECTED_COMMANDS.keys())
NEED_RC |= {"rc", "deploy", "store"}
Expand Down
24 changes: 1 addition & 23 deletions regolith/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,14 @@
from regolith.database import connect

from regolith import commands
from regolith import storage
from regolith.builder import BUILDERS
from regolith.commands import INGEST_COLL_LU
from regolith.helper import HELPERS
from regolith.runcontrol import DEFAULT_RC, load_rcfile, filter_databases
from regolith.schemas import SCHEMAS
from regolith.tools import update_schemas
from regolith import __version__

DISCONNECTED_COMMANDS = {
"rc": lambda rc: print(rc._pformat()),
"deploy": commands.deploy,
"store": storage.main,
"json-to-yaml": commands.json_to_yaml,
"yaml-to-json": commands.yaml_to_json,
}

CONNECTED_COMMANDS = {
"add": commands.add_cmd,
"ingest": commands.ingest,
"app": commands.app,
"grade": commands.grade,
"build": commands.build,
"email": commands.email,
"classlist": commands.classlist,
"validate": commands.validate,
"helper": commands.helper,
"fs-to-mongo": commands.fs_to_mongo,
"mongo-to-fs": commands.mongo_to_fs
}
from regolith.commands import DISCONNECTED_COMMANDS, CONNECTED_COMMANDS

NEED_RC = set(CONNECTED_COMMANDS.keys())
NEED_RC |= {"rc", "deploy", "store"}
Expand Down
1 change: 1 addition & 0 deletions regolith/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from .sorters import POSITION_LEVELS


SORTED_POSITION = sorted(POSITION_LEVELS.keys(), key=POSITION_LEVELS.get)

ACTIVITIES_TYPES = ["teaching", "research"]
Expand Down

0 comments on commit fd209dc

Please sign in to comment.