Skip to content

Commit 3590e9d

Browse files
authored
Merge pull request cfpb#1037 from nickgrippin/panel-docs
Update panel docs and error messages
2 parents c232421 + 15a1502 commit 3590e9d

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

Documents/panel.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
# Panel CSV Parser
1+
# Panel CSV Loader
22

33
## Overview
4-
The panel parser 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.
4+
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.
5+
6+
## 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.
8+
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.
10+
11+
For loading panel data into a remote system, you'll need to set the following environment variables:
12+
```shell
13+
> export HMDA_HTTP_ADMIN_HOST={ip address}
14+
> export HMDA_HTTP_ADMIN_PORT={port #}
15+
```
516

617
## Running the parser
7-
An example panel file is located at `hmda-platform/panel/src/main/resources/inst_data_2017_dummy.csv`
18+
A small example file is located at `panel/src/main/resources/inst_data_2017_dummy.csv`
819

9-
In order for the panel data to be loaded, the API project must be up and running, along with Docker containers running Cassandra and Zookeper. In a terminal, execute the following commands:
20+
The real panel file is located at `panel/src/main/resources/inst_data_2017.csv`
21+
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:
1023

1124
```shell
1225
> sbt
1326
sbt> project panel
14-
sbt> clean
1527
sbt> run /path/to/panelData.csv
1628
```
1729

@@ -21,6 +33,15 @@ sbt> clean
2133
sbt> assembly
2234
```
2335
Then the panel loader can be run with `java -jar panel/target/scala-2.12/panel.jar path/to/institution_file.csv`
36+
37+
## Error codes
38+
There are four ways the panel loader can fail. The exit code and error message should tell you what happened.
39+
40+
1. There were no command line arguments passed to the loader
41+
2. The path passed to the loader didn't point to a file
42+
3. The call to `institutions/create` didn't return the correct response. This can indicate that you don't have the correct environment variables set, or that something is wrong with the hmda-platform.
43+
4. The loader didn't finish processing all the institutions. This will happen when running the real panel file, but unsure as to why this happens.
44+
2445
## Testing
2546
Make sure your authorization header is updated with a few real `id_rssd` fields from the given file. This can be found in the API log output (first field argument in the `InstitutionQuery` object), or in the CSV file (seventh field).
2647

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ $ sbt
104104
project panel
105105
run <full local path to sample file>
106106
```
107-
A sample file is located in the following folder: `hmda-platform/persistence/src/main/resources/demoInstitutions.csv`
107+
A sample file is located in the following folder: `panel/src/main/resources/inst_data_2017_dummy.csv`
108108

109109

110110
* In order to support the read side, a local PostgreSQL and Cassandra server are needed. Assuming it runs on the default port, on the same machine as the API, the following environment variable needs to be set:

panel/src/main/scala/hmda/panel/PanelCsvLoader.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package hmda.panel
22

33
import java.io.File
44

5-
import akka.{ Done, NotUsed }
5+
import akka.NotUsed
66
import akka.actor.ActorSystem
77
import akka.util.{ ByteString, Timeout }
88
import akka.stream.ActorMaterializer
9-
import akka.stream.scaladsl.{ FileIO, Flow, Framing, Sink, Source }
9+
import akka.stream.scaladsl.{ FileIO, Flow, Framing, Sink }
1010
import akka.http.scaladsl.Http
1111
import akka.http.scaladsl.model.{ HttpEntity, _ }
1212
import akka.http.scaladsl.unmarshalling.Unmarshal
@@ -18,8 +18,6 @@ import hmda.parser.fi.InstitutionParser
1818
import org.slf4j.LoggerFactory
1919
import spray.json._
2020

21-
import scala.util.Try
22-
2321
object PanelCsvLoader extends WriteInstitutionProtocol {
2422
implicit val system: ActorSystem = ActorSystem("hmda")
2523
implicit val materializer = ActorMaterializer()
@@ -96,6 +94,7 @@ object PanelCsvLoader extends WriteInstitutionProtocol {
9694

9795
private def exitSys(errorMessage: String, code: Int) = {
9896
log.error(errorMessage)
97+
Thread.sleep(100)
9998
sys.exit(code)
10099
}
101100
}

0 commit comments

Comments
 (0)