Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
JessyBarrette committed Aug 20, 2024
2 parents 3555768 + 05bca10 commit ed3c66d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CODEOWNER
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* @JessyBarrette
* @n-a-t-e
* @JorinHakai
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you just want to see how a dataset is harvested by CDE:
- Rename .env.sample from the root directory to .env and change any settings if needed. If you are running on your local machine these settings don't need to change

- Start a local database using `docker`:
`docker-compose up db -d`
`docker-compose up -d db`
- Setup Python virtual env and install Python modules:

```sh
Expand Down
20 changes: 12 additions & 8 deletions harvester/cde_harvester/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
load_dotenv()

logging.getLogger("urllib3").setLevel(logging.WARNING)
logger = logging.getLogger()

sentry_sdk.init(
dsn=os.environ.get("SENTRY_DSN"),
integrations=[
Expand All @@ -38,15 +40,17 @@

def setup_logging(log_time, log_level):
# setup logging
logging.basicConfig(
level=logging.getLevelName(log_level.upper()),
format=(
"%(asctime)s - %(name)s : %(message)s"
if log_time
else "%(name)s : %(message)s"
),
logger.setLevel(logging.getLevelName(log_level.upper()))
logger.handlers.clear()
# Define the stream log format and level
c_handler = logging.StreamHandler()
c_handler.setLevel(logging.getLevelName(log_level.upper()))
c_format = logging.Formatter(
("%(asctime)s - " if log_time else "")
+ "%(levelname)-8s - %(name)s : %(message)s"
)
logger = logging.getLogger()
c_handler.setFormatter(c_format)
logger.addHandler(c_handler)
return logger


Expand Down
16 changes: 11 additions & 5 deletions harvester/cde_harvester/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def get_eovs(self):
return eovs

def get_platform_code(self):
platform = self.globals["platform"]
platform = self.globals.get("platform")
platform_vocabulary = self.globals.get("platform_vocabulary")

if not (platform and platform_vocabulary):
Expand All @@ -278,13 +278,20 @@ def get_platform_code(self):
subset=["l06_label"]
)

if platform in list(platforms_nerc_ioos["l06_label"]):
if platform.lower() in list(platforms_nerc_ioos["l06_label"]):
return platforms_nerc_ioos_no_duplicates.query(
f"l06_label=='{platform}'"
f"l06_label=='{platform.lower()}'"
)["category"].item()
else:
self.logger.error("Found unsupported L06 platform: %s", platform)

self.logger.warning(
"Found platform='%s' without known vocabulary='%s', setting to 'unknown'",
platform,
platform_vocabulary,
)
return "unknown"

def get_metadata(self):
"get all the global and variable metadata for a dataset"

Expand Down Expand Up @@ -354,8 +361,7 @@ def get_metadata(self):
filter(None, set([globals_dict.get(x) for x in organization_fields]))
)

if self.globals.get("platform"):
self.platform = self.get_platform_code()
self.platform = self.get_platform_code()

def get_logger(self):
logger = logging.getLogger(f"{self.erddap_server.domain} - {self.id}")
Expand Down

0 comments on commit ed3c66d

Please sign in to comment.