generated from patel-zeel/pip-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dc59cf
commit 7885e50
Showing
17 changed files
with
1,764 additions
and
1,046 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## To generate `README.md` file | ||
|
||
Run the command `python README.py` in the terminal. This will generate the `README.md` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- align h1 to center --> | ||
<h1 align="center"> | ||
Garuda | ||
</h1> | ||
|
||
<p align="center"> | ||
<img src="logo/garuda_profile_full1.png" width="100%"> | ||
</p> | ||
<p align="center"> | ||
A research-oriented computer vision library for satellite imagery. | ||
</p> | ||
|
||
[![Coverage Status](https://coveralls.io/repos/github/patel-zeel/garuda/badge.svg?branch=main)](https://coveralls.io/github/patel-zeel/garuda?branch=main) | ||
|
||
## Installation | ||
|
||
Stable version: | ||
|
||
```bash | ||
pip install garuda | ||
``` | ||
|
||
Latest version: | ||
|
||
```bash | ||
pip install git+https://github.com/patel-zeel/garuda | ||
``` | ||
|
||
## Usage | ||
|
||
See the [examples](examples) directory for more details. | ||
|
||
## Functionality | ||
|
||
### Configuration | ||
|
||
#### Disable/Enable TQDM | ||
|
||
```python | ||
{{ config_tqdm }} | ||
``` | ||
|
||
Output: | ||
```python | ||
{{ config_tqdm_output }} | ||
``` | ||
|
||
#### Adjust log level | ||
|
||
```python | ||
{{ config_log_level }} | ||
``` | ||
|
||
Output: | ||
```python | ||
{{ config_log_level_output }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import io | ||
import ast | ||
import jinja2 | ||
import contextlib | ||
from README_codes import * | ||
import logging | ||
from garuda.base import logger, log_format | ||
|
||
# Read the README codes | ||
with open("README_codes.py", "r") as f: | ||
readme_codes = ast.parse(f.read()) | ||
|
||
function_body_dict = {} | ||
output_dict = {} | ||
for node in ast.walk(readme_codes): | ||
if isinstance(node, ast.FunctionDef) and not node.name.startswith("_"): | ||
function_code = ast.unparse(node) | ||
function_body_code = ast.unparse(node.body) | ||
function_body_dict[node.name] = function_body_code.strip() | ||
|
||
# Get the function | ||
# exec(compile(ast.parse(function_code), filename="<ast>", mode="exec")) | ||
function = locals()[node.name] | ||
|
||
output_stream = io.StringIO() | ||
|
||
# Set up a custom logging handler | ||
handler = logging.StreamHandler(output_stream) | ||
handler.setFormatter(logging.Formatter(log_format)) | ||
logger.addHandler(handler) | ||
|
||
# Execute it and capture the output | ||
with contextlib.redirect_stdout(output_stream), contextlib.redirect_stderr(output_stream): | ||
function() | ||
|
||
# Save the output | ||
output = output_stream.getvalue() | ||
output_dict[f"{node.name}_output"] = output.strip() | ||
|
||
# Read the README template | ||
template_path = "README.jinja2" | ||
with open(template_path, "r") as f: | ||
template = f.read() | ||
template = jinja2.Template(template) | ||
|
||
# Render the template | ||
kwargs = {**function_body_dict, **output_dict} | ||
rendered = template.render(**kwargs) | ||
|
||
# Write the README | ||
with open("README.md", "w") as f: | ||
f.write(rendered) | ||
|
||
print(rendered) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
def config_tqdm(): | ||
from garuda.config import enable_tqdm, disable_tqdm | ||
|
||
enable_tqdm() # Enable tqdm progress bar across the library | ||
disable_tqdm() # Disable tqdm progress bar across the library | ||
|
||
def config_log_level(): | ||
from garuda.config import set_log_level | ||
from garuda.base import logger | ||
|
||
def _log_everything(): | ||
logger.debug("Debug message") | ||
logger.info("Info message") | ||
logger.warning("Warning message") | ||
logger.error("Error message") | ||
logger.critical("Critical message") | ||
|
||
# default log level is INFO | ||
set_log_level("DEBUG") | ||
_log_everything() | ||
|
||
set_log_level("INFO") | ||
_log_everything() | ||
|
||
set_log_level("WARNING") | ||
_log_everything() | ||
|
||
set_log_level("ERROR") | ||
_log_everything() | ||
|
||
set_log_level("CRITICAL") | ||
_log_everything() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.