Skip to content

Commit b1eaa2a

Browse files
committed
Merge branch 'master' of https://github.com/cfpb/hmda-platform
2 parents 5a3292c + bd9f5df commit b1eaa2a

File tree

122 files changed

+433
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+433
-338
lines changed

Documents/panel.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@
44
The panel loader is designed to read a CSV file and load the data onto the HMDA-Platform. The CSV file should use the `|` (pipe) delimiter, and should include a header row as the first line.
55

66
## Environment Variables
7-
There are two environment variables used by the panel loader. Both must be set correctly in order for the data to be sent to the admin API.
7+
There is only one environment variable used by the panel loader. It must be set correctly in order for the data to be sent to the admin API.
88

9-
For testing locally, no changes need to be made. The defaults for both of these variables will point to the correct local admin API.
9+
For testing on an API running in SBT, no changes need to be made. The default for this variable will point to the correct local admin API.
1010

11-
For loading panel data into a remote system, you'll need to set the following environment variables:
11+
For loading panel data into a remote system or into a local Docker container, you'll need to set the following environment variable:
1212
```shell
13-
> export HMDA_HTTP_ADMIN_HOST={ip address}
14-
> export HMDA_HTTP_ADMIN_PORT={port #}
13+
> export HMDA_HTTP_ADMIN_URL={base URL}
14+
```
15+
16+
**IMPORTANT NOTE:** The base URL should *include* `http://` or `https://`, but *exclude* any trailing backslash `/`. For example:
17+
18+
```shell
19+
> export HMDA_HTTP_ADMIN_URL=http://192.168.99.100:8081
1520
```
1621

1722
## Running the parser
1823
A small example file is located at `panel/src/main/resources/inst_data_2017_dummy.csv`
1924

2025
The real panel file is located at `panel/src/main/resources/inst_data_2017.csv`
2126

22-
In order for the panel data to be loaded locally, the API project must be up and running, along with Docker containers running Cassandra and Zookeper. Otherwise, no other running services are needed (but make sure your environment variables are set). In a terminal, execute the following commands:
27+
In order for the panel data to be loaded locally, the API project must be up and running, along with Docker containers running Cassandra and Zookeper, or run the full `docker-compose` setup. To load panel data into the cluster, simply find the URL of the admin api (for the release branch: `https://hmda-ops-api.demo.cfpb.gov/admin`). No other running services are necessary.
28+
29+
In a terminal, execute the following commands:
2330

2431
```shell
2532
> sbt

README.md

Lines changed: 115 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ export ZOOKEEPER_HOST=192.168.99.100
144144
export ZOOKEEPER_PORT=2181
145145
```
146146

147+
Alternatively, these dependencies (`Cassandra`, `Zookeeper` and `PostgreSQL`) can be started from `docker` providing default resources for the `HMDA Platform`:
148+
149+
`docker-compose -f docker-dev.yml up`
150+
151+
* If you want to use the sample files in this repo for testing the app, run the edits in demo mode. Otherwise, edit S025 will trigger for all files.
152+
153+
```shell
154+
export EDITS_DEMO_MODE=true
155+
```
156+
147157
* Start `sbt`
148158

149159
```shell
@@ -208,51 +218,124 @@ The Filing API will run on `$(docker-machine ip):8080`
208218
The Public API will run on `$(docker-machine ip):8082`
209219

210220
#### To run the entire platform
211-
Clone the [HMDA Platform UI](https://github.com/cfpb/hmda-platform-ui) repo and the [HMDA Platform Auth](https://github.com/cfpb/hmda-platform-auth) repo into sibling directories of this one. Your directory structure should look like this:
212-
```shell
213-
~/dev/hmda-project$ ls -la
214-
total 16
215-
drwxr-xr-x 6 lortone staff 204B Jul 25 17:44 ./
216-
drwxr-xr-x 9 lortone staff 306B Jul 25 17:50 ../
217-
drwxr-xr-x 22 lortone staff 748B Jul 27 16:28 hmda-platform/
218-
drwxr-xr-x 25 lortone staff 850B Jul 25 17:13 hmda-platform-ui/
219-
drwxr-xr-x 23 lortone staff 796B Jul 28 17:15 hmda-platform-auth/
220-
```
221221

222-
From the _`hmda-platform-ui`'s_ root directory, run `yarn`. (Get yarn [here](https://yarnpkg.com/lang/en/docs/install/) if you don't have it installed.)
222+
1. Dedicate appropriate resources to your Docker environment. We've found
223+
that for the full stack to run efficiently, you need approximately:
223224

224-
From _`hmda-platform`'s_ root directory, run the following:
225+
* 4 CPUs
226+
* 6 GB RAM
227+
* 80 GB Disk space
225228

226-
```shell
227-
sbt clean assembly
228-
docker-compose up
229-
```
229+
Assuming you are using Docker Machine to provision your Docker
230+
environment, you can check you current settings with the following
231+
(ignore the second `Memory`):
230232

231-
This will bring up all the HMDA Platform services. The first run may take several minutes.
233+
$ docker-machine inspect | grep 'CPU\|Memory\|DiskSize'
234+
"CPU": 4,
235+
"Memory": 6144,
236+
"DiskSize": 81920,
237+
"Memory": 0,
232238

233-
Next, find your docker machine's endpoint.
239+
If your settings are below these suggestions, you should create a new
240+
Docker VM. The following will create a VM named `hmda-platform` with
241+
the appropriate resources:
234242

235-
```shell
236-
# Typically defaults to 192.168.99.100, which will be used in the following examples
237-
docker-machine ip dev
238-
```
243+
$ docker-machine create \
244+
--driver virtualbox \
245+
--virtualbox-disk-size 81920 \
246+
--virtualbox-cpu-count 4 \
247+
--virtualbox-memory 6144 \
248+
hmda-platform
249+
250+
1. Clone [hmda-platform-ui](https://github.com/cfpb/hmda-platform-ui) and
251+
[hmda-platform-auth](https://github.com/cfpb/hmda-platform-auth) into the same
252+
directory as hmda-platform.
253+
254+
~/dev/hmda-project$ ls -l
255+
drwxr-xr-x 22 lortone staff 748B Jul 27 16:28 hmda-platform/
256+
drwxr-xr-x 25 lortone staff 850B Jul 25 17:13 hmda-platform-ui/
257+
drwxr-xr-x 23 lortone staff 796B Jul 28 17:15 hmda-platform-auth/
258+
259+
1. Build hmda-platform-ui
260+
261+
cd hmda-platform-ui && \
262+
yarn && \
263+
cd ..
264+
265+
**Note:** This requires [yarn](https://yarnpkg.com/lang/en/docs/install/) to be installed.
266+
267+
1. Build hmda-platform
268+
269+
cd hmda-platform && \
270+
sbt clean assembly
271+
272+
1. Launch the stack with Docker Compose
273+
274+
docker-compose up
275+
276+
This will bring up all the HMDA Platform services. The first run may take several minutes.
277+
278+
1. Discover your Docker host's IP
279+
280+
echo $DOCKER_HOST
281+
282+
...or if using Docker Machine...
283+
284+
docker-machine ip
285+
286+
**Note:** Docker Machine generally defaults to `192.168.99.100`. We reference that
287+
IP throught this doc. If your Docker host IP differs, please adjust these instructions
288+
to match the Docker host IP provided by your system.
289+
290+
1. Use it! Below are steps representing a standard HMDA filing:
291+
292+
1. Browse to the app at http://192.168.99.100.
293+
1. Select the "Login" button. This will redirect your browser to the Keycloak login screen.
294+
1. Select "create and account" on the login screen.
295+
1. Enter you account information and select "Register".
296+
297+
**Note:** You must register with an email address from our whitelist of email domains.
298+
For convenience, `bank0.com` and `bank1.com` address should be available automatically.
299+
300+
1. Browse to the mock email server at https://192.168.99.100:8443/mail/, and select the
301+
verification link in the email found there. This should take you back to the HMDA
302+
filing web app, now logged in.
303+
304+
**Note:** This "MailDev" services is for development purposes only. In the case of
305+
an actual HMDA filing, you would receive a confirmation to your actual email account.
306+
307+
1. Submit a HMDA filing. Several sample files can be found [here](https://github.com/cfpb/hmda-platform/tree/master/parser/jvm/src/test/resources/txt).
239308

240-
Then, visit the following URLS and click advanced -> proceed. This will bypass self-signed cert errors from your browser when running the app.
309+
##### Updating an existing system
241310

242-
- https://192.168.99.100:8443/
243-
- https://192.168.99.100:4443/
244-
- https://192.168.99.100:9443/
311+
If you've updated any of the hmda-platform services, and would like to see those
312+
changes reflected in the Docker Compose setup, the simplest way to do this is to
313+
rebuild everything from scratch. The following command should be executed from
314+
within the `hmda-platform` directory.
245315

246-
Visit the app at http://192.168.99.100, click the "Login" button, and click "Register" when redirected to the keycloak login screen.
316+
docker-compose stop -t0 && \
317+
docker-compose rm -vf && \
318+
cd ../hmda-platform-ui && \
319+
yarn && \
320+
cd ../hmda-platform && \
321+
sbt clean assembly && \
322+
docker-compose build --no-cache && \
323+
docker-compose up
247324

248-
To use demo data there are two institutions available; Bank 0 and Bank 1. To register for either of these institutions you have to use the corresponding domain:
249325

250-
- Bank 0 = bank0.com
251-
- Bank 1 = bank1.com
326+
##### Service URLs
252327

253-
Confirm your signup via MailDev by visiting http://192.168.99.100:1080, opening the email, and clicking the verifying link.
328+
When running the full stack via Docker Compose, the following services are available:
254329

255-
You can now interact with the app/begin uploading files, etc.
330+
| Service | URL |
331+
|------------------------|-------------------------------------|
332+
| Filing UI | https://192.168.99.100 |
333+
| Filing API (Unsecured) | http://192.168.99.100:8080 |
334+
| Filing API (Secured) | https://192.168.99.100:4443/hmda/ |
335+
| Admin API | http://192.168.99.100:8081 |
336+
| Public API | https://192.168.99.100:4443/public/ |
337+
| Keycloak | https://192.168.99.100:8443 |
338+
| MailDev | https://192.168.99.100:8443/mail/ |
256339

257340
#### Development conveniences
258341

api/src/main/resources/application.conf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,29 @@ hmda {
6262
timeout = 10
6363
timeout = ${?HMDA_HTTP_TIMEOUT}
6464
}
65-
isDemo = true
65+
isDemo = false
6666
isDemo = ${?HMDA_IS_DEMO}
6767
zookeeperHost = "192.168.99.100"
6868
zookeeperHost = ${?ZOOKEEPER_HOST}
6969
zookeeperPort = 2181
7070
zookeeperPort = ${?ZOOKEEPER_PORT}
7171
}
7272

73+
api-dispatcher {
74+
type = Dispatcher
75+
executor = "fork-join-executor"
76+
fork-join-executor {
77+
# Min number of threads to cap factor-based parallelism number to
78+
parallelism-min = 2
79+
# Parallelism (threads) ... ceil(available processors * factor)
80+
parallelism-factor = 2.0
81+
# Max number of threads to cap factor-based parallelism number to
82+
parallelism-max = 10
83+
}
84+
# Throughput defines the maximum number of messages to be
85+
# processed per actor before the thread jumps to the next actor.
86+
# Set to 1 for as fair as possible.
87+
throughput = 100
88+
}
89+
7390

api/src/main/scala/hmda/api/HmdaFilingApi.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package hmda.api
22

3-
import akka.actor.{ ActorRef, ActorSystem, Props }
3+
import akka.actor.{ ActorSystem, Props }
44
import akka.event.Logging
55
import akka.http.scaladsl.Http
66
import akka.http.scaladsl.Http.ServerBinding
77
import akka.http.scaladsl.server.Directives._
88
import akka.http.scaladsl.server.Route
9-
import akka.pattern.{ ask, pipe }
9+
import akka.pattern.pipe
1010
import akka.stream.ActorMaterializer
1111
import akka.util.Timeout
12-
import com.typesafe.config.ConfigFactory
1312
import hmda.api.http.{ BaseHttpApi, HmdaCustomDirectives, InstitutionsHttpApi, LarHttpApi }
1413
import hmda.api.HmdaConfig._
1514
import scala.concurrent.duration._

api/src/main/scala/hmda/api/HmdaPlatform.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import hmda.query.projections.filing.HmdaFilingDBProjection._
2424
import hmda.validation.ValidationStats
2525
import hmda.api.HmdaConfig._
2626
import hmda.query.HmdaProjectionQuery
27-
import hmda.query.projections.institutions.InstitutionCassandraProjection
2827

2928
object HmdaPlatform {
3029

@@ -35,7 +34,7 @@ object HmdaPlatform {
3534
val system = ActorSystem(configuration.getString("clustering.name"), configuration)
3635
val supervisor = createSupervisor(system)
3736
val querySupervisor = createQuerySupervisor(system)
38-
implicit val ec = system.dispatcher
37+
implicit val ec = system.dispatchers.lookup("api-dispatcher")
3938

4039
startActors(system, supervisor, querySupervisor)
4140
startApi(system, querySupervisor)

api/src/main/scala/hmda/api/http/ValidationErrorConverter.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import hmda.model.edits.EditMetaDataLookup
66
import hmda.model.fi.{ HmdaFileRow, HmdaRowError }
77
import hmda.model.validation.ValidationError
88
import hmda.persistence.processing.HmdaFileValidator.HmdaFileValidationState
9-
import hmda.validation.engine._
109
import spray.json.{ JsNumber, JsObject, JsString, JsValue }
1110

1211
trait ValidationErrorConverter {

api/src/main/scala/hmda/api/http/institutions/FilingPaths.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import hmda.persistence.HmdaSupervisor.{ FindFilings, FindSubmissions }
1919
import hmda.persistence.institutions.FilingPersistence.GetFilingByPeriod
2020
import hmda.persistence.institutions.{ FilingPersistence, SubmissionPersistence }
2121

22-
import scala.concurrent.{ ExecutionContext, Future }
22+
import scala.concurrent.Future
2323
import scala.util.{ Failure, Success }
2424

2525
trait FilingPaths extends InstitutionProtocol with ApiErrorProtocol with HmdaCustomDirectives {

api/src/main/scala/hmda/api/http/institutions/InstitutionPaths.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import hmda.persistence.model.HmdaSupervisorActor.FindActorByName
2222
import hmda.query.view.institutions.InstitutionView
2323
import hmda.query.view.institutions.InstitutionView.{ GetInstitutionById, GetInstitutionsById }
2424

25-
import scala.concurrent.{ ExecutionContext, Future }
25+
import scala.concurrent.Future
2626
import scala.util.{ Failure, Success }
2727

2828
trait InstitutionPaths extends InstitutionProtocol with ApiErrorProtocol with HmdaCustomDirectives {

api/src/main/scala/hmda/api/http/institutions/UploadPaths.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import hmda.persistence.processing.SubmissionManager
2828
import hmda.query.HmdaQuerySupervisor.FindHmdaFilingView
2929
import hmda.query.projections.filing.HmdaFilingDBProjection.{ CreateSchema, DeleteLars }
3030

31-
import scala.concurrent.ExecutionContext
3231
import scala.util.{ Failure, Success }
3332

3433
trait UploadPaths extends InstitutionProtocol with ApiErrorProtocol with SubmissionProtocol with HmdaCustomDirectives {

api/src/main/scala/hmda/api/http/institutions/submissions/SubmissionBasePaths.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@ import akka.util.Timeout
1212
import hmda.api.http.{ HmdaCustomDirectives, ValidationErrorConverter }
1313
import hmda.api.model._
1414
import hmda.api.protocol.processing.{ ApiErrorProtocol, EditResultsProtocol, InstitutionProtocol }
15-
import hmda.model.fi.{ Filing, Submission, SubmissionId }
16-
import hmda.model.validation.Macro
17-
import hmda.persistence.messages.CommonMessages.GetState
18-
import hmda.persistence.HmdaSupervisor.{ FindFilings, FindProcessingActor, FindSubmissions }
15+
import hmda.model.fi.{ Filing, Submission }
16+
import hmda.persistence.HmdaSupervisor.{ FindFilings, FindSubmissions }
1917
import hmda.persistence.institutions.FilingPersistence.GetFilingByPeriod
2018
import hmda.persistence.institutions.SubmissionPersistence.{ CreateSubmission, GetLatestSubmission }
2119
import hmda.persistence.institutions.{ FilingPersistence, SubmissionPersistence }
22-
import hmda.persistence.processing.HmdaFileValidator
23-
import hmda.persistence.processing.HmdaFileValidator.HmdaFileValidationState
2420

2521
import scala.concurrent.ExecutionContext
2622
import scala.util.{ Failure, Success }

0 commit comments

Comments
 (0)