Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weather-dl v2 #408

Merged
merged 52 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
40442fa
Initial Commit.
mahrsee1997 May 16, 2023
f9f4d39
Replaced in-memory db with db layer (FirestoreClient()).
mahrsee1997 May 18, 2023
6d817c3
Updated api_endpoints & added server k8s dep. conf
mahrsee1997 May 19, 2023
a76c24e
Updated 'manifest' system to uses 'database' layer
mahrsee1997 May 19, 2023
600d93a
Updated Dockerfile to create server image.
mahrsee1997 May 19, 2023
019574a
Added nginx server.
mahrsee1997 May 22, 2023
e7101ae
fix linter issues.
mahrsee1997 May 22, 2023
3b3eb69
Inital commit for license deployment.
mahrsee1997 Jun 8, 2023
091d18b
Fix license deployment
mahrsee1997 Jun 9, 2023
ad2fa24
Made changes to deploy license from fastapi server.
mahrsee1997 Jun 9, 2023
2bd3366
Minor directory restructuring.
mahrsee1997 Jun 12, 2023
32b98a2
Minor fixes related to license-deployment.
mahrsee1997 Jun 12, 2023
ee8de36
weather-dl-v2 `cli` (#346)
aniketsinghrawat Jun 13, 2023
535ebe2
Made use of google-secret-manager for storing license keys.
mahrsee1997 Jun 14, 2023
b0039d6
Merge branch 'dl-v2' of https://github.com/google/weather-tools into …
mahrsee1997 Jun 14, 2023
0754510
Necessary code changes in weather-dl-v2 cli.
mahrsee1997 Jun 15, 2023
7af5fef
Added CLI & API Interaction doc. & Implemented absolute priority.
mahrsee1997 Jun 27, 2023
86070d2
Removed nginx-server -- not required.
mahrsee1997 Jun 28, 2023
fbb16cf
dl-v2 server refactor no tests (#358)
aniketsinghrawat Jul 17, 2023
257908d
`dl-v2` server integration tests (#359)
aniketsinghrawat Jul 19, 2023
95c9d50
updated cli create-instance command & lint fixes (#364)
aniketsinghrawat Jul 21, 2023
4cc633c
Pending deployment bootup (#366)
aniketsinghrawat Jul 24, 2023
6e797a2
Updated README.md.
mahrsee1997 Jul 24, 2023
2aec32a
formatting by pyink for dl_v2 (#367)
aniketsinghrawat Jul 25, 2023
f68f21a
passing license handler to update license handler (#369)
aniketsinghrawat Jul 26, 2023
430fba1
`dl-v2` server config (#370)
aniketsinghrawat Jul 27, 2023
531a8a6
Added config status to dl-v2-server (#371)
aniketsinghrawat Jul 28, 2023
a532873
`dl-v2` server firestore async client (#375)
aniketsinghrawat Aug 7, 2023
18ce1b7
Implemented force-download.
mahrsee1997 Aug 8, 2023
facc909
await create_deployment call in main.py fast-api server.
mahrsee1997 Aug 8, 2023
a07229e
Improved config partitioning -- maintain status.
mahrsee1997 Aug 8, 2023
2b76056
refetch config (#378)
aniketsinghrawat Aug 9, 2023
8659fd4
Assign download jobs to its dedicated node-pool.
mahrsee1997 Aug 10, 2023
f951db0
`dl-v2` improvements (#380)
aniketsinghrawat Aug 17, 2023
d2dc658
`dl-v2` imporvements 2 (#381)
aniketsinghrawat Aug 17, 2023
e65b5ad
added validation for license id (#382)
aniketsinghrawat Aug 18, 2023
bd9e4d1
`dl-v2` additional download filters (#383)
aniketsinghrawat Aug 22, 2023
26aaedb
`dl-v2` improvements 3 (#384)
aniketsinghrawat Aug 23, 2023
5fcf8a2
`dl-v2` improvements 4 (#386)
aniketsinghrawat Aug 29, 2023
f8bbf7f
`weather-dl-v2` cli show table (#388)
aniketsinghrawat Aug 31, 2023
d5c5272
`dl-v2` server queue client name bug (#389)
aniketsinghrawat Sep 5, 2023
c24cbae
`dl-v2` license dep logger (#390)
aniketsinghrawat Sep 6, 2023
bd3081f
`dl-v2` cli minor updates (#393)
aniketsinghrawat Sep 13, 2023
fc3c8a2
`dl-v2` added gcs storage and updated retry partition (#394)
aniketsinghrawat Sep 14, 2023
bbfe554
`dl-v2` cli doc update (#395)
aniketsinghrawat Sep 15, 2023
bd762e6
`dl v2` config map (#397)
aniketsinghrawat Sep 21, 2023
1b275a4
`dl-v2` pre merge (#403)
aniketsinghrawat Oct 17, 2023
050b7ba
`dl v2` added license to dl-v2 (#405)
aniketsinghrawat Oct 17, 2023
eeeb770
`dl-v2` todos (#407)
aniketsinghrawat Oct 18, 2023
31b718d
`dl v2` lint fixes (#409)
aniketsinghrawat Oct 18, 2023
b809f86
`dl-v2` server test fix (#412)
aniketsinghrawat Oct 27, 2023
f55c756
lint fixes (#413)
aniketsinghrawat Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: python -m metview selfcheck
- name: Run unit tests
shell: bash -l {0}
run: pytest --memray
run: pytest --memray --ignore=weather_dl_v2 # Ignoring dl-v2 as it only supports py3.10
lint:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ target-version = "py310"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
max-complexity = 10
2 changes: 1 addition & 1 deletion weather_dl/download_pipeline/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def to_json_serializable_type(value: t.Any) -> t.Any:
elif type(value) == np.ndarray:
# Will return a scaler if array is of size 1, else will return a list.
return value.tolist()
elif type(value) == datetime.datetime or type(value) == str or type(value) == np.datetime64:
elif isinstance(value, datetime.datetime) or isinstance(value, str) or isinstance(value, np.datetime64):
# Assume strings are ISO format timestamps...
try:
value = datetime.datetime.fromisoformat(value)
Expand Down
12 changes: 12 additions & 0 deletions weather_dl_v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## weather-dl-v2

<!-- TODO: Create a setup script to ease deployment process. -->

> **_NOTE:_** weather-dl-v2 only supports python 3.10

### Sequence of steps:
1) Refer to downloader_kubernetes/README.md
2) Refer to license_deployment/README.md
3) Refer to fastapi-server/README.md
4) Refer to cli/README.md

13 changes: 13 additions & 0 deletions weather_dl_v2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
306 changes: 306 additions & 0 deletions weather_dl_v2/cli/CLI-Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
# CLI Documentation
The following doc provides cli commands and their various arguments and options.

Base Command:
```
weather-dl-v2
```

## Ping
Ping the FastAPI server and check if it’s live and reachable.

<summary><code>weather-dl-v2 ping</code></summary>

##### Usage
```
weather-dl-v2 ping
```


<br>

## Download
Manage download configs.


### Add Downloads
<summary><code>weather-dl-v2 download add</code> <br>
Adds a new download config to specific licenses.
</summary>


##### Arguments
> `FILE_PATH` : Path to config file.

##### Options
> `-l/--license` (Required): License ID to which this download has to be added to.
> `-f/--force-download` : Force redownload of partitions that were previously downloaded.

##### Usage
```
weather-dl-v2 download add /path/to/example.cfg –l L1 -l L2 [--force-download]
```

### List Downloads
<summary><code>weather-dl-v2 download list</code> <br>
List all the active downloads.
</summary>

The list can also be filtered out by client_names.
Available filters:
```
Filter Key: client_name
Values: cds, mars, ecpublic

Filter Key: status
Values: completed, failed, in-progress
```

##### Options
> `--filter` : Filter the list by some key and value. Format of filter filter_key=filter_value

##### Usage
```
weather-dl-v2 download list
weather-dl-v2 download list --filter client_name=cds
weather-dl-v2 download list --filter status=success
weather-dl-v2 download list --filter status=failed
weather-dl-v2 download list --filter status=in-progress
weather-dl-v2 download list --filter client_name=cds --filter status=success
```

### Download Get
<summary><code>weather-dl-v2 download get</code> <br>
Get a particular download by config name.
</summary>

##### Arguments
> `CONFIG_NAME` : Name of the download config.

##### Usage
```
weather-dl-v2 download get example.cfg
```

### Download Show
<summary><code>weather-dl-v2 download show</code> <br>
Get contents of a particular config by config name.
</summary>

##### Arguments
> `CONFIG_NAME` : Name of the download config.

##### Usage
```
weather-dl-v2 download show example.cfg
```

### Download Remove
<summary><code>weather-dl-v2 download remove</code> <br>
Remove a download by config name.
</summary>

##### Arguments
> `CONFIG_NAME` : Name of the download config.

##### Usage
```
weather-dl-v2 download remove example.cfg
```

### Download Refetch
<summary><code>weather-dl-v2 download refetch</code> <br>
Refetch all non-successful partitions of a config.
</summary>

##### Arguments
> `CONFIG_NAME` : Name of the download config.

##### Options
> `-l/--license` (Required): License ID to which this download has to be added to.

##### Usage
```
weather-dl-v2 download refetch example.cfg -l L1 -l L2
```

<br>

## License
Manage licenses.

### License Add
<summary><code>weather-dl-v2 license add</code> <br>
Add a new license. New licenses are added using a json file.
</summary>

The json file should be in this format:
```
{
"license_id: <license_id>,
"client_name": <client_name>,
"number_of_requests": <number_of_request>,
"secret_id": <secret_manager_id>
}
```
NOTE: `license_id` is case insensitive and has to be unique for each license.


##### Arguments
> `FILE_PATH` : Path to the license json.

##### Usage
```
weather-dl-v2 license add /path/to/new-license.json
```

### License Get
<summary><code>weather-dl-v2 license get</code> <br>
Get a particular license by license ID.
</summary>

##### Arguments
> `LICENSE` : License ID of the license to be fetched.

##### Usage
```
weather-dl-v2 license get L1
```

### License Remove
<summary><code>weather-dl-v2 license remove</code> <br>
Remove a particular license by license ID.
</summary>

##### Arguments
> `LICENSE` : License ID of the license to be removed.

##### Usage
```
weather-dl-v2 license remove L1
```

### License List
<summary><code>weather-dl-v2 license list</code> <br>
List all the licenses available.
</summary>

The list can also be filtered by client name.

##### Options
> `--filter` : Filter the list by some key and value. Format of filter filter_key=filter_value.

##### Usage
```
weather-dl-v2 license list
weather-dl-v2 license list --filter client_name=cds
```

### License Update
<summary><code>weather-dl-v2 license update</code> <br>
Update an existing license using License ID and a license json.
</summary>

The json should be of the same format used to add a new license.

##### Arguments
> `LICENSE` : License ID of the license to be edited.
> `FILE_PATH` : Path to the license json.

##### Usage
```
weather-dl-v2 license update L1 /path/to/license.json
```

<br>

## Queue
Manage all the license queue.

### Queue List
<summary><code>weather-dl-v2 queue list</code> <br>
List all the queues.
</summary>

The list can also be filtered by client name.

##### Options
> `--filter` : Filter the list by some key and value. Format of filter filter_key=filter_value.

##### Usage
```
weather-dl-v2 queue list
weather-dl-v2 queue list --filter client_name=cds
```

### Queue Get
<summary><code>weather-dl-v2 queue get</code> <br>
Get a queue by license ID.
</summary>

The list can also be filtered by client name.

##### Arguments
> `LICENSE` : License ID of the queue to be fetched.

##### Usage
```
weather-dl-v2 queue get L1
```

### Queue Edit
<summary><code>weather-dl-v2 queue edit</code> <br>
Edit the priority of configs inside queues using edit.
</summary>

Priority can be edited in two ways:
1. The new priority queue is passed using a priority json file that should follow the following format:
```
{
“priority”: [“c1.cfg”, “c3.cfg”, “c2.cfg”]
}
```
2. A config file name and its absolute priority can be passed and it updates the priority for that particular config file in the mentioned license queue.

##### Arguments
> `LICENSE` : License ID of queue to be edited.

##### Options
> `-f/--file` : Path of the new priority json file.
> `-c/--config` : Config name for absolute priority.
> `-p/--priority`: Absolute priority for the config in a license queue. Priority increases in ascending order with 0 having highest priority.

##### Usage
```
weather-dl-v2 queue edit L1 --file /path/to/priority.json
weather-dl-v2 queue edit L1 --config example.cfg --priority 0
```

<br>

## Config
Configurations for cli.

### Config Show IP
<summary><code>weather-dl-v2 config show-ip</code> <br>
See the current server IP address.
</summary>

##### Usage
```
weather-dl-v2 config show-ip
```

### Config Set IP
<summary><code>weather-dl-v2 config set-ip</code> <br>
See the current server IP address.
</summary>

##### Arguments
> `NEW_IP` : New IP address. (Do not add port or protocol).

##### Usage
```
weather-dl-v2 config set-ip 127.0.0.1
```

Loading
Loading