Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 3f9c79d

Browse files
committed
Add unix details, and dependency versions
1 parent df925b8 commit 3f9c79d

7 files changed

+31
-24
lines changed

README.md

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# First Street Foundation API Access Documentation (Python)
1+
# First Street Foundation API Access Documentation (Python 3.6+)
22
[![CircleCI](https://img.shields.io/circleci/build/gh/FirstStreet/fsf_api_access_python)](https://circleci.com/gh/FirstStreet/fsf_api_access_python)
33
![GitHub](https://img.shields.io/github/license/firststreet/fsf_api_access_python)
44

@@ -49,10 +49,11 @@ Current release: 0.1
4949

5050
![Screenshot](doc/images/1.2.3.png)
5151

52-
3. Open `git bash` and create then navigate to a new project directory
52+
3. Open `git bash` or a `bash terminal` (if on a MacOS or Linux) and create then navigate to a new project directory
5353

5454
```sh
5555
mkdir fsf_api
56+
5657
cd fsf_api
5758
```
5859

@@ -74,7 +75,7 @@ Current release: 0.1
7475

7576
![Screenshot](doc/images/1.3.1.png)
7677

77-
5. [Optional] Open a new console or close and re-open a console and create and activate a new virtual environment in the project directory:
78+
5. [Optional] Open a new `powershell console` / `bash terminal` or close and re-open a console and create and activate a new virtual environment in the project directory:
7879
```sh
7980
python -m venv /path/to/new/virtual/environment
8081
@@ -111,15 +112,24 @@ Current release: 0.1
111112
## [Running the Project - Method 1: Through the Command Line](#toc)
112113
**[Reminder] Keep your API key safe, and do not share it with others!**
113114
114-
1. [Required] Set an Environmental Variable with the `variable_name` as `FSF_API_KEY` and the `variable_value` with the `API_KEY`.
115+
[NOTE] This method will always generate a CSV.
116+
117+
1. ## **MacOS or Linux**
118+
[Required] Open a `bash terminal` and set an Environmental Variable with the `variable_name` as `FSF_API_KEY` and the `variable_value` with the `API_KEY` with the command
119+
```shell script
120+
export FSF_API_KEY=your personal API key
121+
```
122+
123+
## **Windows**
124+
[Required] Set an Environmental Variable with the `variable_name` as `FSF_API_KEY` and the `variable_value` with the `API_KEY`.
115125

116126
![Screenshot](doc/images/3.1.1.png)
117127

118128
![Screenshot](doc/images/3.1.2.png)
119129

120130
![Screenshot](doc/images/3.1.3.png)
121131

122-
2. Open a new console and navigate to the project directory. Next, call one of the methods described below in the `Products` section through the command line. See the `Examples` section for more examples.
132+
2. Open/Re-open a `powershell console` / `bash terminal` and navigate to the project directory. Next, call one of the methods described below in the `Products` section through the command line. See the `Examples` section for more examples.
123133
```sh
124134
cd /path/to/project
125135
python -m firststreet -p <product>.<product_subtype> -i <fsids> -f <file_name> -l <lookup_type>
@@ -180,6 +190,8 @@ Current release: 0.1
180190
## [Running the Project - Method 2: Through the Client](#toc)
181191
**[Reminder] Keep your API key safe, and do not share it with others!**
182192

193+
[NOTE] This method will **NOT** generate a CSV by default. An argument must be passed to generate a CSV.
194+
183195
1. Create a new Python script (by using notepad or any other text editor) and initialize a First Street Foundation API Client.
184196
```python
185197
# Contents of my_script.py
@@ -218,6 +230,9 @@ Current release: 0.1
218230

219231
<a name="products"></a>
220232
# [Products](#toc)
233+
234+
**NOTE**: As of the current release, only direct FSID lookups are available through this wrapper. Lat/lng and address query will be in a later release
235+
221236
<a name="location"></a>
222237
#### [Location](#toc)
223238

@@ -444,7 +459,7 @@ If an update is made to this project, you will need to pull the changes from git
444459

445460
![Screenshot](doc/images/6.1.1.png)
446461

447-
2. Open a new console, navigate to the project, and re-run the setup script to re-install the project:
462+
2. Open a new `powershell console` / `bash terminal`, navigate to the project, and re-run the setup script to re-install the project:
448463

449464
```shell script
450465
cd /path/to/project

firststreet/api/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def call_api(self, fsids, product, product_subtype, location, limit=100):
3838
"""
3939
if not isinstance(fsids, list):
4040
if isinstance(fsids, str):
41-
if os.path.isfile(os.getcwd() + "\\" + fsids):
42-
fsids = read_fsid_file(os.getcwd() + "\\" + fsids)
41+
if os.path.isfile(os.getcwd() + "console/terminal" + fsids):
42+
fsids = read_fsid_file(os.getcwd() + "/" + fsids)
4343
else:
4444
raise InvalidArgument("File provided is not a valid file. "
4545
"Please check the file name. '{}'".format(os.path.curdir + str(fsids)))

firststreet/api/csv_format.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# Standard Imports
55
import datetime
6+
import logging
67
import os
78

89
# External Imports
@@ -29,7 +30,7 @@ def to_csv(data, product, product_subtype, location_type=None, output_dir=None):
2930
file_name = "_".join([date, product, product_subtype]) + ".csv"
3031

3132
if not output_dir:
32-
output_dir = os.getcwd() + "\\data_csv"
33+
output_dir = os.getcwd() + "/data_csv"
3334

3435
if not os.path.exists(output_dir):
3536
os.makedirs(output_dir)
@@ -137,6 +138,7 @@ def to_csv(data, product, product_subtype, location_type=None, output_dir=None):
137138
# Export CSVs
138139
df.fillna(pd.NA, inplace=True)
139140
df.to_csv(output_dir + '/' + file_name, index=False)
141+
logging.info("CSV generated to '{}'.".format(output_dir + '/' + file_name))
140142

141143

142144
def format_adaptation_detail(data):

requirements.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp
2-
shapely
3-
pandas
4-
tqdm
1+
aiohttp >= 3.6.2
2+
shapely >= 1.7.0
3+
pandas >= 1.0.5
4+
tqdm >= 4.46.1

tests/temp/test_full02020_06_25_12_40_03_adaptation_detail.csv

-9
This file was deleted.

tests/temp/test_full02020_06_25_12_40_40_adaptation_summary_property.csv

-2
This file was deleted.

tests/test_full.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_full(tmpdir):
2828
fs.probability.get_count([39047], 'county', csv=True, output_dir=tmpdir)
2929
fs.probability.get_count([3904], 'cd', csv=True, output_dir=tmpdir)
3030
fs.probability.get_count([39], 'state', csv=True, output_dir=tmpdir)
31+
fs.probability.get_count_summary([394406220], csv=True, output_dir=tmpdir)
3132
fs.probability.get_cumulative([390000439], csv=True, output_dir=tmpdir)
3233
fs.probability.get_depth([390000227], csv=True, output_dir=tmpdir)
3334
fs.environmental.get_precipitation([39057], csv=True, output_dir=tmpdir)

0 commit comments

Comments
 (0)