-
Notifications
You must be signed in to change notification settings - Fork 68
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
Update Configuration class to support merging objects in local config files #782
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1e32ed1
Initial Configuration Consolidation + Tests
ryanrath 4cd8423
Adding Required Test Artifacts
ryanrath 5f039d5
Adding newlines per travis
ryanrath 9edf843
Account for adding a newline @ the end of json files
ryanrath 69f85ad
Ensure generated json files have newline @ the end
ryanrath 617a204
Derrrrr
ryanrath 3ef5389
Updates per @smgallo code review comments
ryanrath 02c7f5a
Adding newline
ryanrath 92c5900
Updates per @smgallo
ryanrath 5d3ff5a
Merge branch 'xdmod8.1' into refactor_config
ryanrath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,48 @@ | ||
<?php | ||
|
||
namespace Configuration; | ||
|
||
use CCR\Loggable; | ||
use Log; | ||
use stdClass; | ||
|
||
/** | ||
* Class StripMergePrefixTransformer | ||
* | ||
* This class allows config files designed to work with `Config` to work with the new | ||
* `Configuration` class. It accomplishes this by stripping the merge prefix "+" from keys. This | ||
* works because the default merge behavior of `Configuration` is the same as `Config` w/ '+' | ||
* prefixed keys. | ||
* | ||
* @package Configuration | ||
*/ | ||
class StripMergePrefixTransformer extends Loggable implements iConfigFileKeyTransformer | ||
{ | ||
const MERGE_PREFIX = '+'; | ||
|
||
/** | ||
* @see iConfigFileKeyTransformer::__construct() | ||
*/ | ||
public function __construct(Log $logger = null) | ||
{ | ||
parent::__construct($logger); | ||
} | ||
|
||
/** | ||
* @see iConfigFileKeyTransformer::keyMatches() | ||
*/ | ||
public function keyMatches($key) | ||
{ | ||
return substr($key, 0, 1) === self::MERGE_PREFIX; | ||
} | ||
|
||
/** | ||
* @see iConfigFileKeyTransformer::transform() | ||
*/ | ||
public function transform(&$key, &$value, stdClass $obj, Configuration $config) | ||
{ | ||
$key = substr($key, 1, strlen($key) - 1); | ||
|
||
return true; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
tests/artifacts/xdmod-test-artifacts/xdmod/configuration/input/xdmod_config.json
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,14 @@ | ||
[ | ||
[ | ||
{ | ||
"section": "roles", | ||
"expected": "xdmod_config_roles.json" | ||
} | ||
], | ||
[ | ||
{ | ||
"section": "datawarehouse", | ||
"expected": "xdmod_config_datawarehouse.json" | ||
} | ||
] | ||
] |
1 change: 1 addition & 0 deletions
1
...acts/xdmod-test-artifacts/xdmod/configuration/output/xdmod_config_datawarehouse.json.json
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 @@ | ||
{"realms":{"Jobs":{"schema":"modw_aggregates","table":"jobfact","datasource":"HPcDB","group_bys":[{"name":"none","class":"GroupByNone"},{"name":"nodecount","class":"GroupByNodeCount"},{"name":"person","class":"GroupByPerson"},{"name":"pi","class":"GroupByPI"},{"name":"resource","class":"GroupByResource"},{"name":"resource_type","class":"GroupByResourceType"},{"name":"nsfdirectorate","class":"GroupByNSFDirectorate"},{"name":"parentscience","class":"GroupByParentScience"},{"name":"fieldofscience","class":"GroupByScience"},{"name":"jobsize","class":"GroupByJobSize"},{"name":"jobwalltime","class":"GroupByJobTime"},{"name":"jobwaittime","class":"GroupByJobWaitTime"},{"name":"queue","class":"GroupByQueue"},{"name":"username","class":"GroupByUsername"},{"name":"day","class":"GroupByDay"},{"name":"month","class":"GroupByMonth"},{"name":"quarter","class":"GroupByQuarter"},{"name":"year","class":"GroupByYear"},{"name":"provider","class":"GroupByProvider","visible":false}],"statistics":[{"name":"job_count","class":"JobCountStatistic"},{"name":"job_count","class":"JobCountStatistic"},{"name":"running_job_count","class":"RunningJobCountStatistic","control":true},{"name":"started_job_count","class":"StartedJobCountStatistic","control":true},{"name":"submitted_job_count","class":"SubmittedJobCountStatistic"},{"name":"active_person_count","class":"ActiveUserCountStatistic"},{"name":"active_pi_count","class":"ActivePICountStatistic"},{"name":"total_cpu_hours","class":"TotalCPUHoursStatistic"},{"name":"total_waitduration_hours","class":"TotalWaitHoursStatistic"},{"name":"total_node_hours","class":"TotalNodeHoursStatistic"},{"name":"total_wallduration_hours","class":"TotalWallHoursStatistic"},{"name":"avg_cpu_hours","class":"AverageCPUHoursStatistic"},{"name":"sem_avg_cpu_hours","class":"SEMAverageCPUHoursStatistic","visible":false},{"name":"avg_node_hours","class":"AverageNodeHoursStatistic"},{"name":"sem_avg_node_hours","class":"SEMAverageNodeHoursStatistic","visible":false},{"name":"avg_waitduration_hours","class":"AverageWaitHoursStatistic"},{"name":"sem_avg_waitduration_hours","class":"SEMAverageWaitHoursStatistic","visible":false},{"name":"avg_wallduration_hours","class":"AverageWallHoursStatistic"},{"name":"sem_avg_wallduration_hours","class":"SEMAverageWallHoursStatistic","visible":false},{"name":"avg_processors","class":"AverageProcessorCountStatistic"},{"name":"sem_avg_processors","class":"SEMAverageProcessorCountStatistic","visible":false},{"name":"min_processors","class":"MinProcessorCountStatistic"},{"name":"max_processors","class":"MaxProcessorCountStatistic"},{"name":"utilization","class":"UtilizationStatistic"},{"name":"expansion_factor","class":"ExpansionFactorStatistic"},{"name":"normalized_avg_processors","class":"NormalizedAverageProcessorCountStatistic"},{"name":"avg_job_size_weighted_by_cpu_hours","class":"JobSizeWeightedByCPUHours"},{"name":"active_resource_count","class":"ActiveResourceCountStatistic"}]},"Storage":{"schema":"modw","table":"storagefact","datasource":"Storage usage logs","group_bys":[{"name":"none","class":"GroupByNone"},{"name":"day","class":"GroupByDay"},{"name":"month","class":"GroupByMonth"},{"name":"quarter","class":"GroupByQuarter"},{"name":"year","class":"GroupByYear"},{"name":"resource","class":"GroupByResource"},{"name":"resource_type","class":"GroupByResourceType"},{"name":"mountpoint","class":"GroupByMountpoint"},{"name":"person","class":"GroupByPerson"},{"name":"pi","class":"GroupByPI"},{"name":"username","class":"GroupByUsername"},{"name":"nsfdirectorate","class":"GroupByNSFDirectorate"},{"name":"parentscience","class":"GroupByParentScience"},{"name":"fieldofscience","class":"GroupByScience"}],"statistics":[{"name":"user_count","class":"UserCountStatistic"},{"name":"avg_file_count","class":"FileCountStatistic"},{"name":"sem_file_count","class":"SemFileCountStatistic","visible":false},{"name":"avg_logical_usage","class":"LogicalUsageStatistic"},{"name":"sem_logical_usage","class":"SemLogicalUsageStatistic","visible":false},{"name":"avg_physical_usage","class":"PhysicalUsageStatistic"},{"name":"sem_physical_usage","class":"SemPhysicalUsageStatistic","visible":false},{"name":"avg_hard_threshold","class":"HardThresholdStatistic"},{"name":"avg_soft_threshold","class":"SoftThresholdStatistic"},{"name":"avg_logical_utilization","class":"LogicalUtilizationStatistic"}]},"Cloud":{"schema":"modw_cloud","table":"cloudfact","datasource":"Cloud","group_bys":[{"name":"none","class":"GroupByNone"},{"name":"project","class":"GroupByProject"},{"name":"configuration","class":"GroupByConfiguration"},{"name":"resource","class":"GroupByResource"},{"name":"day","class":"GroupByDay"},{"name":"month","class":"GroupByMonth"},{"name":"quarter","class":"GroupByQuarter"},{"name":"year","class":"GroupByYear"},{"name":"vm_size_memory","class":"GroupByVMMemory"},{"name":"vm_size","class":"GroupByVMCores"},{"name":"submission_venue","class":"GroupBySubmissionVenue"}],"statistics":[{"name":"cloud_num_sessions_ended","class":"SessionsCountStatistic"},{"name":"cloud_num_sessions_running","class":"RunningSessionsCountStatistic","control":true},{"name":"cloud_num_sessions_started","class":"StartedSessionsCountStatistic","control":true},{"name":"cloud_avg_wallduration_hours","class":"AverageWallHoursStatistic"},{"name":"cloud_core_time","class":"CoreHoursStatistic"},{"name":"cloud_wall_time","class":"WallHoursStatistic"},{"name":"cloud_avg_cores_reserved","class":"WeightedCoresReservedStatistic"},{"name":"cloud_avg_memory_reserved","class":"AverageMemoryReservedStatistic"},{"name":"cloud_avg_rv_storage_reserved","class":"AverageRootVolumeStorageReservedStatistic"}]}}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't we need the check that both of these values are scalars? Otherwise if the existing value is an object and the incoming value is a scalar we will hit this clause. We should provide a warning here as well if we have a type mismatch.
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.
Actually, if we fix up this method can't we just call it from the
merge()
method and get rid of the if-then-else there?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.
I think we still need to be able to handle types other than Object at the top level but it's entirely possible I'm missing something.