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

Update config read order #818

Merged
merged 18 commits into from
Mar 13, 2019
Merged

Conversation

ryanrath
Copy link
Contributor

Description

Updating the order in which Configuration classes read / process their local config files, if present, to be in alphabetical order.

Motivation and Context

It's desirable to have these files processed in some deterministic manner as opposed to however the FS decides to return them.

Tests performed

Unit test added that ensures the local config files are processed in alphabetical order.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project as found in the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ryanrath ryanrath added the enhancement Enhancement of the functionality of an existing feature label Feb 26, 2019
plessbd
plessbd previously approved these changes Feb 28, 2019
@ryanrath ryanrath requested review from plessbd and jpwhite4 and removed request for plessbd March 5, 2019 17:53
ryanrath and others added 9 commits March 8, 2019 08:55
Previously the order in which local config files were read / processed was
non-deterministic. In this case, returned in an order as determined by the
underlying file system. It is desirable that we be able to control the order in
which these files are processed so the code has been changed to first, read all
the files from the specified directory in fs order, saving them in an array.
Next, sort this array in a deterministic array ( we default to sorting the
entries as strings ). Last, process these files as they were previously.
Just adding a test to ensure that local config files are read / processed in
alphabetical order.
Updated the `testLocalConfigReadOrder` function to not use a string comparison
as this was causing problems when run on Travis. Instead it is now using an
object comparison.
Updates per @plessbd, just making sure that the expected output is pretty
printed.
Updates per code review by @jpwhite4

Co-Authored-By: ryanrath <[email protected]>
removing local scoped variable as it's not needed.
Switching to the new `XdmodConfiguration` class incurred a lot of boilerplate
overhead. This helper function + making local config directories implicit when
instantiating a new `Configuration` object means that we can remove basically
all of the boilerplate that was added previously.

**NOTE:** The instances where `rawstatistics.json` was being read were not
          working as expected due to there being a type mismatch between the
          base config file and its local config files. This PR updates the way
          in which the config data is being used to be in line with how the
          config files will be going forward. There will be separate PR's to
          update the local config files, specifically in the SUPREMM model.
  # Please enter the commit message for your changes. Lines starting
ryanrath and others added 8 commits March 8, 2019 08:55
the `datawarehouse` test specified in `xdmod_config.json` didn't need a
`local_dir` so this was removed. To account for some entries having a local_dir
and others not I updated the config object construction to account for this.
`$configFile` no longer exists so we instead use `CONFIG_DIR` for building the
file name to use in case of an exception.
Forgot add the `['realms']` qualification to the code that populates
`$realmExists`.
Now that we have this nice new helper function it makes sense to use it.
@ryanrath ryanrath merged commit 4dd15f6 into ubccr:xdmod8.1 Mar 13, 2019
jtpalmer pushed a commit to jtpalmer/xdmod that referenced this pull request Mar 13, 2019
* Adding sorting to local config file processing

Previously the order in which local config files were read / processed was
non-deterministic. In this case, returned in an order as determined by the
underlying file system. It is desirable that we be able to control the order in
which these files are processed so the code has been changed to first, read all
the files from the specified directory in fs order, saving them in an array.
Next, sort this array in a deterministic array ( we default to sorting the
entries as strings ). Last, process these files as they were previously.

* Adding test for local config read order

Just adding a test to ensure that local config files are read / processed in
alphabetical order.

* Adding newlines

* Updating test logic

Updated the `testLocalConfigReadOrder` function to not use a string comparison
as this was causing problems when run on Travis. Instead it is now using an
object comparison.

* Pretty printing expected output

Updates per @plessbd, just making sure that the expected output is pretty
printed.

* Update classes/Configuration/Configuration.php

Updates per code review by @jpwhite4

Co-Authored-By: ryanrath <[email protected]>

* Updates per code review comment by @jpwhite4

removing local scoped variable as it's not needed.

* Added a new helper function `assocArrayFactory`

Switching to the new `XdmodConfiguration` class incurred a lot of boilerplate
overhead. This helper function + making local config directories implicit when
instantiating a new `Configuration` object means that we can remove basically
all of the boilerplate that was added previously.

**NOTE:** The instances where `rawstatistics.json` was being read were not
          working as expected due to there being a type mismatch between the
          base config file and its local config files. This PR updates the way
          in which the config data is being used to be in line with how the
          config files will be going forward. There will be separate PR's to
          update the local config files, specifically in the SUPREMM model.
  # Please enter the commit message for your changes. Lines starting

* Formatting fixes

* Updated `local_dir` to be optional

the `datawarehouse` test specified in `xdmod_config.json` didn't need a
`local_dir` so this was removed. To account for some entries having a local_dir
and others not I updated the config object construction to account for this.

* Missed refactor

`$configFile` no longer exists so we instead use `CONFIG_DIR` for building the
file name to use in case of an exception.

* Updating rawstatistics.realms to an array

* Missed

Forgot add the `['realms']` qualification to the code that populates
`$realmExists`.

* Updating to utilize the new `assocArrayFactory`

Now that we have this nice new helper function it makes sense to use it.

* Update classes/Rest/Controllers/WarehouseControllerProvider.php

per @jpwhite4

Co-Authored-By: ryanrath <[email protected]>

* Fixing Syntax

* Only process `extends` if not a local config file
jpwhite4 added a commit to jpwhite4/xdmod that referenced this pull request Mar 13, 2019
jpwhite4 added a commit that referenced this pull request Mar 13, 2019
jtpalmer pushed a commit to jtpalmer/xdmod that referenced this pull request Mar 15, 2019
@plessbd plessbd added this to the 8.1.0 milestone Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the functionality of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants