Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

[LRP2] Hydra-ize local play and server deploys. #309

Merged
merged 1,543 commits into from
Dec 9, 2022
Merged

[LRP2] Hydra-ize local play and server deploys. #309

merged 1,543 commits into from
Dec 9, 2022

Conversation

JackUrb
Copy link
Contributor

@JackUrb JackUrb commented Aug 18, 2022

Overview

As LIGHT moves to having a single codebase that's supposed to deploy in many locations (devfairs, local development, production, etc), our previous method of passing opts around everywhere, doing initializations inline, and rewriting configuration parsing in multiple places is no longer flying. This PR consolidates around Hydra, pushing our configuration into StructuredConfigs and the hydra_configs directory.

Illustration
One big upside of this change is that configuration can either be compositional or written out to a single file. It also supports different schemas for different setups, such that:

# deploy/local.yaml
# @package _global_

defaults:
  - /light/model_pool: baseline
  - /schema/light/db: local
  - /light/db: local

hostname: localhost
port: 35494
safety_classifier_path: ""
is_logging: false
tutorial_builder: null

light:
  model_root: ~/LIGHT/models/

and

# deploy/prod.yaml
# @package _global_

defaults:
  - /light/model_pool: remote
  - /schema/light/db: aws-postgres
  - /light/db: prod

hostname: www.light-rpg.ai
port: 8080
safety_classifier_path: ""
is_logging: True
password: ""
disable_builder: true

light:
  model_root: /home/ubuntu/data/models/

can both be used to configure the same run_server.py launch script, even though the /light/model_pool: baseline default is set to load ParlAI models in-line, and /light/model_pool: remote is set to connect to a series of remote addresses (based on the contents of hydra_configs/light/model_pool/remote). Similarly, the arguments for local and aws-postgres database schemas are entirely different, but we can pull values from each properly.

Implementation

Big fixes

  • ModelPool now implements a get_from_config_async method, which initializes a complete ModelPool from the ModelPoolConfig class (which dynamically has a field for every standard key in ModelTypeName).
  • GraphBuilders and ModelLoader classes now set a CONFIG_CLASS which points to the correct structured config class that can be used to initialize them. hydra_registry.py can then use these to initialize the configs as schemas as well as a baseline default. Introduces a base_model_loader module to have better inheritance patterns.
  • InteractionLoggers are no longer registered on creation of an OOGraph. These are instead created when the World is assigned an OOGraph, as the graph itself is just the representation of state, and the World has higher level configuration about a running game. These thus instead initialize on a World as well, and many callsites are changed to reflect this.

Following changes

  • With hydra_registry.py set up, we now initialize it in the main import light call such that all confs are available.
  • Some missing opts that used to be passed to OOGraphs have been added to the WorldConfig. Callsites are updated to include these where appropriate.
  • ModelServer cleanup - now that we use hydra args, we can directly pass these along to the hydra pool to do the entirety of initialization.
  • OOGraph no longer takes an opt, instead getting title and db_id as optional fields. Many callsites updated.
  • Main Server opt deprecation:
    • GameInstance no longer takes in opt, instead wanting a GraphBuilderConfig to initialize the builder for it's games, and a WorldConfig to feed that builder when initializing worlds.
    • RegistryApplication no longer takes in opt or a LIGHTDatabase, instead getting a WorldServerConfig with everything it needs to initialize GameInstances.
    • run_server.py has been overhauled, now accepting hydra args and deferring model initialization to the ModelPool
  • Server + Deploy config migration:
    • JS configs are stored in the server, python configs have all been centralized into hydra yamls.
    • build and deploy scripts now provide the hydra arguments and correct .js config files.
  • Restructuring play_map.py to be hydra-safe
  • Made some typing additions to keep sanity through all this

Discussions + Comments

  1. While hydra_registry.py is required as a centralized place for all of actually registering configuration into the hydra system, the configs and subconfigs right now I've localized with what they configure (ie. MapJsonBuilderConfig is in the same file as MapJsonBuilder) for proximity/understanding. I've seen other structures of keeping these elsewhere to prevent dependency loops (configs and schemas in one place, implementations elsewhere), but I was wondering if that was really necessary here.
  2. The whole TornadoPlayerProvider, GameInstance, RegistryApplication architecture of the main game server is something of a sprawling mess. This is due for a refactor into the WorldServer and LandingServer setup noted in the internal design doc, so please forgive the somewhat messy architecture here.
  3. Wrapping run-scripts in @hydra.main as well as establishing the script configs feels a little boiler-plate-y but abstracting it into a @light_script(config=<>) may be hiding too much of it into magic. Unsure where I land here.

TODO

  • Minimum functioning implementation
  • Make setting password to "" disable login via password entirely.
  • (in a follow-up PR) update the rest of the builders

Testing

  • Automated tests are passing
  • Local play_map.py, run_server.py, and model_server.py are working
  • Dev and prod deploy are working.

JustinPinero and others added 30 commits May 13, 2021 20:20
* fixed spacing issue from help message

* fixed sizing issue on tutorial screen
* fixed spacing issue from help message

* fixed sizing issue on tutorial screen

* fixing borders and sizing issues

* added styles for mobile landscape view

* fixed fixed positioning in mobile view

* cleared unused styles

* fixed progress bar text

* fixed text and nameplate styling and landing app tutorial page

* added space at footer for landing app pages
* Merging _human and is_player

* Removing old function

* No longer true case about cap on characters
* fixed spacing issue from help message

* fixed sizing issue on tutorial screen

* fixing borders and sizing issues

* added styles for mobile landscape view

* fixed fixed positioning in mobile view

* cleared unused styles

* fixed progress bar text

* fixed text and nameplate styling and landing app tutorial page

* added space at footer for landing app pages

* added views

* updating structure

* added example card component

* added copy arrays, styling example cards, and building good example list

* styled example list components

* styling preview view

* adjusted content and overflow to be right of it's label, fixed intro copy, fixed coloring in details section

* fixed details interaction copy

* fixed alignment of example card content

* building button

* fixed placement of definitions and added spacing

* pre-merge

* added error and success toats

* added screenshot to tutorial, added toast to submit

* duplicated previous task

* formatting constraint events task

* fixed conf

* restructuring app

* building multiple choice

* added answer form

* built reusable question components, added copy, building and styling forms

* added fieldQuestion component

* added fieldrow component

* added attributesetter component

* added constraints component and questions

* styled question components, headers, and layout

* added multiple select question component

* built attribute setter, attribute row, and added dummy data

* styled attribute setter

* connected dummy Data, restyled events and constraint containers, colored object names

* added copy updates from initial thoughts, added location description question

* added taskdatacards and datacard component

* styling cards and field row border

* added formatquestion component

* minor style fixes on field row, added formatquestion component to task card

* added format question component to boolean question component

* fixed formatquestion component

* added drop down component and submit checklist components

* fixed positioning and fixing numbering for questions

* added delete functionality to attribute setter

* added and styled submission component

* Adding new example copy, passing name and descriptions (#245)

* pre pull

* pre pull

* Fixing clobbered run_task.py (#246)

* Adding new example copy, passing name and descriptions

* Fixing run_task.py

* Fixing script config

* successfully updated run_task

* added and styled description to object selector, form tips, and preview image

* fixed payload update

* updated example card component with primary and secondary desc and styled text

* updated example card component with primary and secondary desc and styled text

* Task2 submit (#248)

* adding state for payload

* added error state

* centralizing copy

* added isReversible, removeItems, isRemovingItems isCreatingEntity, createdEntity, isSecondaryHeld state

* building updatedRemoveObjects

* added create entity event to submission handler

* added events and constraints handling and packaging for payload submission

* wired constraint and event state to constraint and event components

* connected new copy object to events

* wiring task 2

* wiring event forms

* fixed field row styles

* added tooltip component, building preview and tutorial copy object

* added task 2 tutorial copy, added and styled tutorial entry component, added and styled preview view

* updated copy for preview and updated layout

* added screenshots for Preview

* finishing final submission and preview changes

* fixed create entity connection to submission

* connected constraints and fixed submission state

* building error handling and checklist component logic

* building error handling and checklist component logic

* added error key to task copy file

* added error toasts, error key, and completion checkboxes component

* fixed checkbox, restyled headers, added plus icon to add attribute button

* fixed error handling for broadcast messsage and item description changes

* fixed attribute setter connection to submission payload

* added documentation to components, removed console logs, fixed tooltip styling, and added mephisto handleSubmit to submit function

* Fixed spacing, removed improperly placed checkboxes, updated  copy, updated screenshots

* merge

* Finalizing Narrations pilot (#257)

* Moving files

* Importing new examine script

* Updated review scripts

* Final changes for pilot

* dropped configs

* style changes based on user feedback

* Missing css class

* Fixing run, fixing copy

* Updating Attributes task final pilot

* Is safe is light task (#256)

* Troubleshooting image loading issue

* added task4, added multiple choice, added run tas and yaml files, build task state

* added task4, added multiple choice, added run tas and yaml files, build task state

* added Sucess and Error Banners

* added copy to task copy, restructuring QuestionBlock component

* added format question, updated taskcopy, added header to QuestionBlock

* added tooltip component

* added checkbox component

* restyled question block orietation, removed unused styles

* added error handling and submissionhandler

* properly styled error banner

* fixed submission issues

* added bootstrap styles, updated comments on Question Block and multiplechoice components, added more copy for preview

* several minor styling fixes, checkbox positioning, alert color, etc

* Task2 locationupdate (#254)

* Troubleshooting image loading issue

* added, connected, and styled onSelectQuestion component for handling location change event

* added, connected, and styled onSelectQuestion component for handling location change event

* added error handling for new location

* removed console.logs from question on select and converted inline styles to classes

* Updating folder location

Co-authored-by: Jack Urbanek <[email protected]>

* Merging task 3 into crowdsourcing ui (#260)

* Troubleshooting image loading issue

* initial setup complete

* building Actor Block

* adding actor block draw functionality

* adding actor block draw functionality

* added styles, building window size state

* added getDimensions utility function, added dimension state to scale component, connectect state to konva stage

* added scale range optionblock footer, styled scale question component and subcomponents, connected dummy data from app.js to task component

* added color gradient for scale, fixing some border styling, and sizing issues

* fixed styling and fixed drag boundaries

* adding more informative variables and comments, fixed boundaries, tooling with flag sizing

* added GetFlagDimensions util function, breaking down scale component into scalefield scalerange scale flag selection gallery components

* fixed scaleRange component to map through array of ranges replacing previous hardcoded values

* changed ScaleRange component name to ScaleFooter

* change pixels to percentages in scalerange section width

* added documentation to ScaleQuestion component

* Fixed left boundary, broke flags and selection gallery into components

* fixing flag placement

* Added input header, added documentation, fixed leftSoftBoundary, fixed left flagpole shift, added rating value to selection state

* building task copy and dummy data

* added task copy

* wiring task copy into question components

* added tagrow and tagquestion

* styled attributes tag question

* added datatype switch for testing

* added conditional rendering to number form in tag question

* added state to tokenizer

* added ref to tokenizer, added header to copy, added header prop to tag question

* Task3 scale component (#249)

* building Actor Block

* adding actor block draw functionality

* adding actor block draw functionality

* added styles, building window size state

* added getDimensions utility function, added dimension state to scale component, connectect state to konva stage

* added scale range optionblock footer, styled scale question component and subcomponents, connected dummy data from app.js to task component

* added color gradient for scale, fixing some border styling, and sizing issues

* fixed styling and fixed drag boundaries

* adding more informative variables and comments, fixed boundaries, tooling with flag sizing

* added GetFlagDimensions util function, breaking down scale component into scalefield scalerange scale flag selection gallery components

* fixed scaleRange component to map through array of ranges replacing previous hardcoded values

* changed ScaleRange component name to ScaleFooter

* change pixels to percentages in scalerange section width

* added documentation to ScaleQuestion component

* Fixed left boundary, broke flags and selection gallery into components

* fixing flag placement

* Added input header, added documentation, fixed leftSoftBoundary, fixed left flagpole shift, added rating value to selection state

* pre payload branch

* added scaled attribute basevalues

* added updateHandler

* fixed attributeupdatehandler

* fixed boolean payload change handler

* fixed custom scale rating and input

* fixed numberic attribute handler

* added numeric attributes array

* added multiple select question and Usefulness scale

* added default questions for each type to task copy

* added attribute questions component and added more documentation to Task component

* fixing tag question component added tooltip component

* updated defaultAttribute questions styles and update functions

* fixed multiple choice component

* added selection consideration to multiplechoice component

* added more informative error banner

* tested submit successfully

* fixed scale component header alignment

* premerge changes, added to tutorial copy

* pre merge

* removed labels from custom attribute scale, added better variables describing fixed number values in scale field, fixed indentation in multiplechoice component, changed placeholder message in tagrow

* Task3 preview (#253)

* added attributeChecklist screenshots

* added tutorial screenshots

* added final screenshot for attributeRadio

* added images to TaskCopy.js

* added copy and screenshots for scales and type specific tutorials

* populated preview with tutorial entry components using taskcopy

* added new screenshots to attributeradio2, attributeradio3 assets, styled preview

* added check for 4 custom boolean attributes

* changed header text color to dark blue

Co-authored-by: Justin Pinero <[email protected]>
Co-authored-by: JustinPinero <[email protected]>

* Moving task3

* Moving safe-light task

Co-authored-by: Justin Pinero <[email protected]>
Co-authored-by: JustinPinero <[email protected]>
… local state in game page, sidebar, mobile header
Copy link
Contributor

@mojtaba-komeili mojtaba-komeili left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not fully understand how the password was checked. I see that it is using Tornado's 3rd party Authentication. But don't know much about that. But overall looks ok to me.

@JackUrb JackUrb changed the base branch from refactor-phase-2-full-deploy to new-data-model December 9, 2022 20:30
Base automatically changed from new-data-model to main December 9, 2022 20:31
@JackUrb JackUrb changed the base branch from main to refactor-phase-2-full-deploy December 9, 2022 20:34
@JackUrb JackUrb changed the base branch from refactor-phase-2-full-deploy to main December 9, 2022 20:34
@JackUrb JackUrb merged commit 80b2674 into main Dec 9, 2022
@JackUrb JackUrb deleted the next-1-hydrize branch December 9, 2022 21:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants