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

Increase readability by placing global constants in a config #219

Merged
merged 10 commits into from
May 11, 2021

Conversation

johnwlambert
Copy link
Contributor

@johnwlambert johnwlambert commented May 7, 2021

Currently, global constants like frame rate and image dimensions are scattered across the codebase, including in data_loading/synchronization_database.py and utils/camera_stats.py. This PR places them in a more intuitive place for the user -- a single config file -- increasing readability for the codebase.

The constants are available by a single import call:

from argoverse.sensor_dataset_config import ArgoverseConfig

from hydra.utils import instantiate


class ImageDimensions(NamedTuple):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these dataclasses now that we support Python >3.6? I believe omegaconf uses dataclasses for their Structured Configs which hydra uses in the backend.

@@ -0,0 +1,54 @@
SensorDatasetConfig:
_target_: argoverse.sensor_dataset_config.SensorDatasetConfig
dataset_name: argoverse1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about having a separate version field? I think it might be cleaner.

_target_: argoverse.sensor_dataset_config.SensorDimensions

ring_front_center:
_target_: argoverse.sensor_dataset_config.ImageDimensions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I would consider encapsulating the functionality of ImageDimensions into an entire SensorConfig (or something similar) with additional functionality.

width: int


class SensorDimensions(NamedTuple):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For configuration classes, what do you think about maintained the Config suffix -- e.g., SensorDimensionsConfig? I've seen that consistently used in other repositories related to Pytorch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the Config suffix -- should be incorporated now

@johnwlambert
Copy link
Contributor Author

Note: structured configs w/ defaults and type validation to be considered in follow-up PR

@johnwlambert johnwlambert merged commit 8c35ab8 into master May 11, 2021
sensors: SensorSuiteConfig


DATASET_NAME = "argoverse1.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "argoverse-v1.1" is a bit more readable. What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed -- I'll update that


DATASET_NAME = "argoverse1.1"

with hydra.initialize_config_module(config_module="argoverse.config"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this being used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being instantiated here so we can do the following elsewhere:

from argoverse.sensor_dataset_config import ArgoverseConfig

and we'll immediately have access to an instantiated class

@@ -0,0 +1,54 @@
SensorDatasetConfig:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be nested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the hierarchy makes it a bit more readable -- a class with 4 fields instead of 11

@johnwlambert johnwlambert deleted the use-config-for-constants branch May 11, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants