Skip to content

Commit

Permalink
Use global constant for description.json (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
hungcs authored Jul 10, 2022
1 parent 5c9cffb commit ee1c3c9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ludwig/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

TEST_STATISTICS_FILE_NAME = "test_statistics.json"

DESCRIPTION_FILE_NAME = "description.json"

PREDICTIONS_PARQUET_FILE_NAME = "predictions.parquet"
PREDICTIONS_SHAPES_FILE_NAME = "predictions.shapes.json"

Expand Down
3 changes: 2 additions & 1 deletion ludwig/utils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import torch

from ludwig.constants import PROC_COLUMN
from ludwig.globals import DESCRIPTION_FILE_NAME
from ludwig.utils.fs_utils import find_non_existing_dir_by_adding_suffix


Expand Down Expand Up @@ -112,7 +113,7 @@ def get_output_directory(output_directory, experiment_name, model_name="run"):


def get_file_names(output_directory):
description_fn = os.path.join(output_directory, "description.json")
description_fn = os.path.join(output_directory, DESCRIPTION_FILE_NAME)
training_stats_fn = os.path.join(output_directory, "training_statistics.json")

model_dir = os.path.join(output_directory, "model")
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_tests/test_model_training_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ludwig.contribs.mlflow import MlflowCallback
from ludwig.experiment import experiment_cli
from ludwig.features.number_feature import numeric_transformation_registry
from ludwig.globals import TRAINING_PREPROC_FILE_NAME
from ludwig.globals import DESCRIPTION_FILE_NAME, TRAINING_PREPROC_FILE_NAME
from ludwig.schema.optimizers import optimizer_registry
from ludwig.utils.data_utils import load_json, replace_file_extension
from ludwig.utils.misc_utils import get_from_registry
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_early_stopping(early_stop, generated_data, tmp_path):

# test existence of required files
train_stats_fp = os.path.join(output_dir, "training_statistics.json")
metadata_fp = os.path.join(output_dir, "description.json")
metadata_fp = os.path.join(output_dir, DESCRIPTION_FILE_NAME)
assert os.path.isfile(train_stats_fp)
assert os.path.isfile(metadata_fp)

Expand Down Expand Up @@ -370,7 +370,7 @@ def test_regularization(generated_data, tmp_path):

# test existence of required files
train_stats_fp = os.path.join(output_dir, "training_statistics.json")
metadata_fp = os.path.join(output_dir, "description.json")
metadata_fp = os.path.join(output_dir, DESCRIPTION_FILE_NAME)
assert os.path.isfile(train_stats_fp)
assert os.path.isfile(metadata_fp)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/test_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from ludwig.constants import TRAINER
from ludwig.experiment import experiment_cli
from ludwig.globals import PREDICTIONS_PARQUET_FILE_NAME, TEST_STATISTICS_FILE_NAME
from ludwig.globals import DESCRIPTION_FILE_NAME, PREDICTIONS_PARQUET_FILE_NAME, TEST_STATISTICS_FILE_NAME
from ludwig.utils.data_utils import get_split_path
from ludwig.visualize import _extract_ground_truth_values
from tests.integration_tests.test_visualization_api import obtain_df_splits
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_output_feature_name(experiment_dir, output_feature=0):
:return output_feature_name: name of the first output feature name
from the experiment
"""
description_file = os.path.join(experiment_dir, "description.json")
description_file = os.path.join(experiment_dir, DESCRIPTION_FILE_NAME)
with open(description_file, "rb") as f:
content = json.load(f)
output_feature_name = content["config"]["output_features"][output_feature]["name"]
Expand Down

0 comments on commit ee1c3c9

Please sign in to comment.