-
Notifications
You must be signed in to change notification settings - Fork 91
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
Global cache_dir
variable for exact, fuzzy, and semantic deduplication
#384
base: main
Are you sure you want to change the base?
Changes from 9 commits
769e2ea
b77139c
337cec8
6d55d8c
622912b
4cb26d5
b001622
0c14626
7486459
053f312
1b1ba30
4b12651
4160471
8a22ace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# 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 | ||
# | ||
# http://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. | ||
|
||
from nemo_curator.utils.file_utils import expand_outdir_and_mkdir | ||
|
||
# Global variable to store the cache directory | ||
_global_cache_dir = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a global variable, we should use the singleton design pattern here, where there is a Subsequently, the init and get methods can be nicely wrapped inside that class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sarahyurick please let me know what you think and whether my comment makes sense to you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! Yes, that makes sense to me. Sorry I haven't gotten back to this earlier, but I expect to have more changes ready next week. |
||
|
||
|
||
def initialize_cache_directory(cache_dir: str): | ||
""" | ||
Initialize and set the global cache directory. | ||
""" | ||
global _global_cache_dir | ||
cache_dir = expand_outdir_and_mkdir(cache_dir) | ||
_global_cache_dir = cache_dir | ||
|
||
|
||
def get_cache_directory() -> str: | ||
""" | ||
Retrieve the global cache directory. | ||
""" | ||
return _global_cache_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also make more sense to call this something else, like
deduplication_outputs
.