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

Redesign Build Deployment Process (External) #961

Merged
merged 96 commits into from
Aug 12, 2024

Conversation

MukuFlash03
Copy link
Contributor

@MukuFlash03 MukuFlash03 commented Mar 26, 2024

This PR serves as the implementation for this issue for redesigning our build and deployment processes across e-mission-server, join, admin-dash, public-dash primarily.

Collaborating on this along with @nataliejschultz .

All four redesign PRs for the external repos:
E-mission-server: #961
Join: e-mission/nrel-openpath-join-page#29
Admin-dash: e-mission/op-admin-dashboard#113
Public-dash: e-mission/em-public-dashboard#125


A rough plan can be:

1st phase

  • Consolidating Differences
    • Minimize the differences in internal and external versions, cleanup unnecessary files, so on.
  • Image_Build_Push.yml:
    • CI / CD via GitHub actions to build and push images to Dockerhub for all four repos based on the current process for e-mission-server.
    • Image build push only builds for that specific repo when merge is made to a specific branch.
    • Additionally, for e-mission-server, image-build-push will now also need to trigger the GitHub action in join, admin-dash, public-dash.

2nd phase:

  • Multi-tier uniform repo structure in nrelopenpath
    • Need to change the internal repos to pull from the externally built images for each repo without duplicating the entire external code repository internally.

Mahadik, Mukul Chandrakant added 2 commits March 21, 2024 11:47
Added a try-catch block similar to how other config files are used in case where actual non-sample file is present else use the sample file.

Can remove the file from internal repo since not needed anymore.
Changed level to DEBUG and formatter set to detailed.

Can keep both external and internal versions same by making external also have the same logging level as internal.

Internal version given priority as detailed logging is better for detecting errors.

Also, debug() statements [~1500] are much more than warning() statements [~50].

Will lose out on all these when external repo is used / run if only WARNING level set as default which is higher than DEBUG level.
@MukuFlash03
Copy link
Contributor Author

Checking in the first initial set of changes for consolidating the differences in the external and internal versions.
These are mostly related to config files based on the differences identified here

Currently included these changes:

  1. secret_list.json
  • Modified code here ./emission/net/auth/secret.py
  • Added try-catch block to load data from secret_list non sample file present, else load from sample file.
  • Now, can be removed from internal repo: nrelopenpath/webapp/conf/net/auth/secret_list.json as well.
    • Changes made in internal repo.

  1. webapp/conf/analysis/debug.conf
  • Removed the entire analysis directory from internal repo: nrelopenpath/webapp/analysis.
    • Changes made in internal repo.

  1. Logging level changed for these files:
    Webapp/conf/log/webserver.conf <-> log/webserver.conf.sample
    analysis/conf/log/intake.conf <-> log/intake.conf.sample
  • Can aim to match both versions by making external also have the same logging level as internal.
  • Internal given priority as detailed logging is better for detecting errors, though it does make logs verbose.
  • Also, DEBUG() statements [~1500] are much more than WARNING statements [~50].
    • Got this count by searching in the code base for logging.debug() and logging.warning(), respectively.
  • Will lose out on all these when external repo is used / run if we still keep level as WARNING.
  • Made both webserver.conf and intake.conf use logging level debug and formatter detailed.
    • File can now be removed internally as it matches external ones; removed log/ directory in both webapp and analysis.

Mahadik, Mukul Chandrakant and others added 13 commits March 28, 2024 21:45
Push.json.sample just has 4 key-value pairs which can be changed to ENV variables internally.

Hence, need to write code to read from Env variables.

Changing emission/net/ext_service/push/notify_interface.py to read from env variables.

Using helper class config.py, based on existing template.

First reading from .json file if exists, else read from env variables.
If env variables are all None, then say that values not configured.
Added new environment variable PROD_STAGE.

If this is set to TRUE, then the debug.conf.internal.json will be selected as the conf file.

Else, the existing try-catch block is executed which either checks for a debug.conf.json or uses the sample file if the former does not exist.

The try part is still valid, since some Test files copy over the sample file as debug.conf.json, then reload the config in eac.reload_config() which would need reading from debug.conf.json as well.

Hence, now three files exist:
- debug.conf.json.sample
- debug.conf.json
- debug.conf.json.internal
This is the first part of the method to share the server image tag between other repositories. It would be shared as tag.txt, which gets overwritten every time the image build runs.
…jq from docker_start_script.sh

Summary:
Currently replaced config file values with environment variables.
Expecting developers to manually set env vars instead of conf files.
So, for instance, running containers using `docker-compose` or `docker run`, need to set these values similarly like push environment variables will need to be set.

Key-value pairs in the webserver config file:
REMOVED: log_base_dir, python_path, log_file
ENV: static_path, 404_redirect, host, port, timeout, auth, aggregate_call_auth

———————————

Changes

1. webserver.conf.sample
- Kept file as it is and changed how values being read in cfc_webapp.py, TestWebserver.py and docker_start_script.sh

2. TestWebserver.py
- In setup(): Storing current original ENV variables, Replacing them with test values
- In teardown(): Restoring original ENV variables

3. cfc_webapp.py
- Removed log_base_dir, python_path, log_file as these were only used in the cfc_webapp.py to read in the value from the config file and not used elsewhere.
- Added environment variables for the other config key-value pairs to avoid dependence on config file and as they were being used in the cfc_webapp.py file.

4. docker_start_script.sh - Removed sed / jq usage for editing webserver.conf.sample.json file and copying over as webserver.conf.json; simply setting the environment variable for WEB_SERVER_HOST now.

-------------------

Special notes:

1. config.json <-> webserver.conf.sample.json
- Some files still use config.json and these changes were made 7-8 years ago (even 10 years ago). This config.json file has the same contents as the current webserver.conf.sample.
- So, webserver.conf.sample.json was actually config.json at some point!
e-mission@a028dec

2. Sed localhost replacement isn’t functionally correct
- The default sample value for server.host is "0.0.0.0".
- But the sed command replaces “localhost” with the ENV variable value.
- Since the localhost keyword itself isn’t there in the sample file, the replacement will not work either.

----------------
Initially, was setting them in the if block if ENV variables already existed.
It wasn’t being set as if condition was being evaluated as False.
But if condition should be mainly to store existing values.
In any case, test values must be set, hence moving it outside if block.
…d / jq use

Details of files changed

1. Start scripts
.docker/docker_start_script.sh
emission/integrationTests/start_integration_tests.sh
setup/tests/start_script.sh

- Changed seq / jq usage to directly set Environment variable to desired value; no need of saving sample file as actual conf json file.

2. Config.py files
emission/core/config.py
emission/net/api/config.py
emission/net/ext_service/push/config.py

- Based this file on emission/analysis/config.py
- Added these to read from conf files if present or environment variables instead of sample files.
- Default values set are taken from sample files.
- check_unset_env_vars() can be used to check whether ALL environment variables are unset.

3. DB, Webapp, Push application usage files
emission/core/get_database.py
emission/net/api/cfc_webapp.py
emission/net/ext_service/push/notify_interface.py

- Changed logic to read using the config.py files that read the non-sample actual config files if present or from the Environment variables instead of sample files.

4. Test Files
emission/integrationTests/storageTests/TestMongodbAuth.py
emission/tests/netTests/TestWebserver.py
emission/tests/netTests/TestPush.py

- Test files that exercise the functionality of the logic in the files in (3).
- Earlier, config files were being replaced with test values and copied over for testing purposes.
- Now, switching to using environment variables - call sent to config files in (2) indirectly via application usage files in (3)
- Following flow is followed in reading from and restoring original environment variables values
	setup()
        - Sets ENV vars by storing original vars if set, then uses test ENV vars as new values
	TestFunc()
        - importing modules named in (3) causes values to be read in, which now reads in newer test values since they set the ENV vars in setup()
        - only those ENV vars in test values are set; unchanged ones left untouched or default values read using os.getenv(var name, default)
	teardown()
        - Unset test ENV vars by using del os.environ[var_name]
        - Restore original values from original dict
test_run_script_empty () and test_run_script_show() were failing
- Was occurring because I had used logging.debug() instead of print()
- Hence std output stream was unable to get the print(“storage not configured”) statement

Some more fixes:
- db.conf incorrectly read instead of webserver.conf in config.py in emisison/net/api
- TestPush had an incomplete test, that was used just for testing purposes to invoke calls on importing the pni module.
- TestWebserver.py changed print() statements to logging.debug()
Assertion Error this time in another CI GitHub actions
Workflow name : test-with-docker

Succeeded earlier when the other test (ubuntu-only-test-with-manual-install) failed:
https://github.com/e-mission/e-mission-server/actions/runs/8658279606/job/23741854476

- This happened since then “storage not configured” wasn’t being printed, which is what the test wants as docker compose is used to set up mongo db container.
- With docker, localhost becomes db as the DB_HOST ENV var or “url” key-value.

SOLVED
- Added if condition to print “storage not configured” only when url value is till equal to sample value “localhost”
Will first check if debug.conf exists, like other conf files.
If it does not, except block then check if PROD_STAGE environment variable is set and whether debug.conf.internal is present.
Else, fall back to sample conf.
Accidentally added this after running all tests.
@nataliejschultz
Copy link
Contributor

nataliejschultz commented Apr 25, 2024

Server testing:

First testing the external code as it currently is by building on the current master image. After creating the db:

$ docker run --name db -d -p 27017:27017 --network emission mongo:4.4.0

I built the container as such:

$ docker run --name em-server-1 -d -e DB_HOST=db -e WEB_SERVER_HOST=0.0.0.0 -e STUDY_CONFIG=stage_program --network emission shankari/e-mission-server:master_2024-04-15--53-23

The container spun up and I ran:

$ docker exec -it em-server-1 /bin/bash

Started the e-mission environment:

Source setup/activate.sh

And ran all the tests:

./runAllTests.sh

Every test was passing but one:

Screenshot 2024-04-24 at 11 01 28 PM

After downloading vim into the container and modifying the file with some prints, I found that the issue was a GET returning a 404. Many trials later, I figured out that the issue was from the docker run command setting STUDY_CONFIG=stage_program, instead of stage-program. After running:
export STUDY_CONFIG=stage-program

All tests passed!

Screenshot 2024-04-24 at 10 08 20 PM

This is in alignment with the success of test-with-docker and ubuntu-only-test-with-manual-install, which essentially do the same thing.

To test the changes that we’ve made, I ran the exact same process as before (without the incorrect environment variable) using the most recently created image from our consolidate-differences image_build_push.yml:

$ docker run --name em-server-1 -d -e DB_HOST=db -e WEB_SERVER_HOST=0.0.0.0 -e STUDY_CONFIG=stage-program --network emission mukuflash03/e-mission-server:image-push-merge_2024-04-24--44-54

./runAllTests worked for this as well.

It is reassuring that the test-with-docker and ubuntu-only-test-with-manual-install runs in our consolidate-differences branch also passed.

@shankari
Copy link
Contributor

shankari commented Apr 25, 2024

@nataliejschultz this only tests previously created images. I don't see you building the images.
By default, image_build_push.yml runs on merges to master, so I am not sure how any previously created image will have any of the changes

@nataliejschultz
Copy link
Contributor

nataliejschultz commented Apr 25, 2024

By default, image_build_push.yml runs on merges to master, so I am not sure how any previously created image will have any of the changes

On the image-push-merge branch, we changed the workflows mentioned above to temporarily run on push to image-push-merge branch for testing. Since the actions are running in @MukuFlash03 's forked repository, shouldn't the changes be checked out?

This is also how the images with the changes have been pushed; running image_build_push.yml on push to image-push merge on the fork.

@nataliejschultz
Copy link
Contributor

Internal repo testing for Analysis:

Started mongo container from scratch:
$ docker run --name db -d -p 27017:27017 --network emission mongo:4.4.0

Cd into copy of nrelopenpath multi-tier branch and build + run:

$ docker build -t int-analysis ./analysis/
$ docker run --name int-analysis-1 -d -e DB_HOST=db -e WEB_SERVER_HOST=0.0.0.0 -e STUDY_CONFIG=stage-program -e PUSH_PROVIDER="firebase" -e PUSH_SERVER_AUTH_TOKEN="Get from firebase console" -e PUSH_APP_PACKAGE_NAME="full package name from config.xml. e.g. edu.berkeley.eecs.emission or edu.berkeley.eecs.embase. Defaults to edu.berkeley.eecs.embase" -e PUSH_IOS_TOKEN_FORMAT="fcm" --network emission int-analysis

Checked to make sure that all of the cmd shell scripts made it into the correct directory, based on the new internal configuration:
Screenshot 2024-04-24 at 11 39 41 PM

Exec into container, start emission environment, and run ./runAllTests.sh:

Screenshot 2024-04-25 at 12 22 32 AM

Tests passed.

Mahadik, Mukul Chandrakant added 2 commits April 25, 2024 02:52
Removed test workflow execution.
Added upload artifact.
Commented image build and push for testing purposes.
Fixed indentation.
Learnt that YAML do not permit using tabs as indentation; spaces allowed.
@nataliejschultz
Copy link
Contributor

Of note: these are currently the only differences between consolidate-differences branch and image-push-merge:
Screenshot 2024-04-25 at 10 23 18 AM

None of the differences are significant to the functionality of the images.

- Remove cat
- Don't set WEB_HOST since it is set in the Dockerfile

Consistent with:
2067055 and
51e16de
@shankari
Copy link
Contributor

shankari commented Aug 7, 2024

Recording the deferred cleanup changes from the first round:

  • Explore whether we can stop uploading the date of of the run as an artifact since we are using an .env file in the dashboards. Also we might want to just rebuild on releases instead of every push anyway.
  • Instead of having two separate files for the analysis config (which then have to be kept in sync), just edit the dev in prod mode to turn off the assertions
  • remove override for WEB_HOST (since it is never overridden) and always only publish on 0.0.0.0
    • this will also allow us to remove the extraneous emission/core/config.py and move the remaining code into the existing DB configuration in emission/core/get_database.py
    • and remove reload_config from emission/net/api/cfc_webapp.py
  • remove emission/net/api/config.py and trim down the set of variables that need to be configured
  • remove the secret auth method since it is unused
  • there are so many copies of config files; if we do end up with a few, refactor to avoid copy-paste and ensure DRY
  • refactor code to store old environment variables before modifying them (put into emission/tests/common.py)

@shankari
Copy link
Contributor

shankari commented Aug 7, 2024

Finished with first round. Going to handle some of the second round of changes because they are annoying me.
Going to handle them myself since time to fix < time to comment and get fixed.

So that we can consolidate all the backwards compat code in one place.

if there is a config file and the environment variable is set, we need to
decide which one wins. We will pull out the code into a common class to ensure
DRY. Once the backwards compat has been removed, this can be merged into
the individual config files
@shankari
Copy link
Contributor

While working on "there are so many copies of config files; if we do end up with a few, refactor to avoid copy-paste and ensure DRY" I use pandas to retrieve fields from the config file

        config_file = open(config_file_name)
        # we only have a single entry in the config json, not an array
        # and there is no way for json_normalize to return a series
        # so we will just take the first row of the dataframe
        loaded_val = pd.json_normalize(json.load(config_file)).iloc[0]
        for var, path in var_path_mapping.items():
            ret_val[var] = loaded_val[path]
        config_file.close()

But this then returns the int values wrapped as numpy

result limit is 250000 of type <class 'numpy.int64'>

======================================================================
ERROR: testGetEntries (__main__.TestTimeSeries)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kshankar/Desktop/data/e-mission/gis_branch_tests/emission/tests/storageTests/TestTimeSeries.py", line 53, in testGetEntries
    self.assertEqual(len(list(ts.find_entries(time_query=tq))), len(self.entries))
  File "/Users/kshankar/Desktop/data/e-mission/gis_branch_tests/emission/storage/timeseries/builtin_timeseries.py", line 207, in find_entries
    (orig_ts_db_count, orig_ts_db_result) = self._get_entries_for_timeseries(self.timeseries_db,
  File "/Users/kshankar/Desktop/data/e-mission/gis_branch_tests/emission/storage/timeseries/builtin_timeseries.py", line 246, in _get_entries_for_timeseries
    ts_db_result.limit(edb.result_limit)
  File "/Users/kshankar/Desktop/data/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/pymongo/cursor.py", line 570, in limit
    raise TypeError("limit must be an integer")
TypeError: limit must be an integer

----------------------------------------------------------------------

Making sure to convert to regular int

            if type(ret_val[var]) is np.int64:
                ret_val[var] = int(ret_val[var])

@shankari
Copy link
Contributor

Finally, I currently pass in both the config file path mappings

    {"DB_HOST": "timeseries.url", "DB_RESULT_LIMIT": "timeseries.result_limit"},

and the default values

    {"DB_HOST": "localhost", "DB_RESULT_LIMIT": 250000})

And then in the actual usage, we just use the values without defaults

url = config["DB_HOST"]
result_limit = config["DB_RESULT_LIMIT"]

That is sub-optimal, since then if the config file is malformed, then we won't have defaults. Since we can retrieve the os environment variables directly, and we are going to retrieve it directly in the future, we should just have the defaults in the main file. That also allows us to avoid passing in two arguments.

1. This will avoid having multiple, almost identical, copies of the same file
2. It will ensure that we read the code primarily in "the new way" from a dict
3. it should make removing the backwards compat layer easier in the future
since we are reading from a dict with a default anyway

Testing done:

```
$ ./e-mission-py.bash emission/tests/storageTests/TestTimeSeries.py
----------------------------------------------------------------------
Ran 8 tests in 18.819s

OK
```
This allows us to troubleshoot the config files and fix them instead of only
falling back to the defaults.
Consistent with
e-mission#961 (comment)
and 7f1be92 (which was the original example
for the database)
Consistent with
e-mission#961 (comment)
and 7f1be92 (which was the original example
for the database)

Testing done:

1. Started the webapp with no overridden config

```
Config file not found, returning a copy of the environment variables instead...
Finished configuring logging for <RootLogger root (WARNING)>
Using auth method skip
Replaced json_dumps in plugin with the one from bson
Changing bt.json_loads from <function <lambda> at 0x10b2b08b0> to <function <lambda> at 0x10bd6a940>
Running with HTTPS turned OFF - use a reverse proxy on production
Bottle v0.13-dev server starting up (using CherootServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.
```

2. Started the webapp with an invalid config override

```
ERROR:root:Expecting ',' delimiter: line 12 column 5 (char 464)
Traceback (most recent call last):
  File "/Users/kshankar/Desktop/data/e-mission/gis_branch_tests/emission/core/backwards_compat_config.py", line 28, in get_config
    loaded_val = pd.json_normalize(json.load(config_file)).iloc[0]
...
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 12 column 5 (char 464)
Config file not found, returning a copy of the environment variables instead...
```

3. Started the webapp with a valid config override

```
Finished configuring logging for <RootLogger root (WARNING)>
Using auth method token_list
Replaced json_dumps in plugin with the one from bson
Changing bt.json_loads from <function <lambda> at 0x10fd2a8b0> to <function <lambda> at 0x1107e5940>
Running with HTTPS turned OFF - use a reverse proxy on production
Bottle v0.13-dev server starting up (using CherootServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.
```
Consistent with
e-mission#961 (comment)
and
- 3dea305 (example for the api)
- 7f1be92 (original example for the database)

Testing done:

```
$ ./e-mission-py.bash emission/tests/netTests/TestPush.py
----------------------------------------------------------------------
Ran 5 tests in 0.276s

OK
```
… common file

This is consistent with
- a0f0c6a (push config)
- 3dea305 (api config)

but ensures that we follow DRY
In 7f1be92, we changed the DB configuration
to be based on environment variables. This changed the output text when
importing the module and launching the script. This change fixes the test
token tests that compare the output text with a baseline to reflect the new
expected text.
Since we now use the standard backwards compat module (a0f0c6a)
So that we can get a full list of the environment variable by grepping
properly

```
$ grep -r 'config.get("[A-Z]' emission/
emission//net/ext_service/push/notify_interface_impl/firebase.py:        self.server_auth_token = push_config.get("PUSH_SERVER_AUTH_TOKEN")
emission//net/ext_service/push/notify_interface_impl/firebase.py:            self.app_package_name = push_config.get("PUSH_APP_PACKAGE_NAME")
emission//net/ext_service/push/notify_interface_impl/firebase.py:        self.is_fcm_format = push_config.get("PUSH_IOS_TOKEN_FORMAT") == "fcm"
emission//net/ext_service/push/notify_interface.py:        return NotifyInterfaceFactory.getNotifyInterface(push_config.get("PUSH_PROVIDER"))
emission//net/api/cfc_webapp.py:server_port = config.get("WEBSERVER_PORT", 8080)
emission//net/api/cfc_webapp.py:socket_timeout = config.get("WEBSERVER_TIMEOUT", 3600)
emission//net/api/cfc_webapp.py:auth_method = config.get("WEBSERVER_AUTH", "skip")
emission//net/api/cfc_webapp.py:aggregate_call_auth = config.get("WEBSERVER_AGGREGATE_CALL_AUTH", "no_auth")
emission//net/api/cfc_webapp.py:not_found_redirect = config.get("WEBSERVER_NOT_FOUND_REDIRECT", "https://nrel.gov/openpath")
emission//core/get_database.py:url = config.get("DB_HOST", "localhost")
emission//core/get_database.py:result_limit = config.get("DB_RESULT_LIMIT", 250000)
```
… runs

The tests failed because we now print all environment variables, and the
`hostname` changes between runs. So comparing the output with the known good
output always fails. We strip out variables that are likely to change over
time (hostname, conda version...) to make this test more robust.

1. We technically only need the hostname right now, but will add the conda
version as well so that we don't get spurious failures when the versions
change
2. this was not an issue earlier because we read the values from the config
file. We now read environment variables, but that brings in variables that we
did not set. So this is a new issue that we need to resolve by stripping them
out for the baseline comparison.

```
$ ./e-mission-py.bash emission/tests/storageTests/TestTokenQueries.py
----------------------------------------------------------------------
Ran 21 tests in 23.591s

OK
```
Comment on lines 58 to 64
static_path = enac.get_config()["static_path"]
server_host = enac.get_config()["server_host"]
server_port = enac.get_config()["server_port"]
socket_timeout = enac.get_config()["socket_timeout"]
auth_method = enac.get_config()["auth_method"]
aggregate_call_auth = enac.get_config()["aggregate_call_auth"]
not_found_redirect = enac.get_config()["not_found_redirect"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this ever tested? I don't think that it would have ever worked.
The format of the webserver.conf does not have the static_path at the top level

{
  "paths" : {
    "static_path" : "webapp/www/",
    "python_path" : "main",
    "log_base_dir" : ".",
    "log_file" : "debug.log"
  },

And we didn't modify the path before returning it

    try:
        config_file = open('conf/net/api/webserver.conf')
        ret_val = json.load(config_file)
        config_file.close()
    except:

@shankari
Copy link
Contributor

@MukuFlash03 @nataliejschultz you may want to look through my commits to get a sense of what a clean PR for this change would have looked like. Note that this is not even the fully clean PR but just to the point that was annoying me
#961 (comment)

There are still open issues to be tackled later, but I am out of time to fix this further at this point.

@shankari
Copy link
Contributor

shankari commented Aug 12, 2024

Now there are even more variables. Let's remove them in the test instead of editing the string.

b'Config file not found, returning a copy of the environment variables instead...\nRetrieved config {\'PYTHONPATH\': \'.\', \'SELENIUM_JAR_PATH\': \'/usr/share/java/selenium-server.jar\', \'NVM_RC_VERSION\': \'\', \'CONDA\': \'/usr/share/miniconda\', \'GITHUB_WORKSPACE\': \'/home/runner/work/e-mission-server/e-mission-server\', \'JAVA_HOME_11_X64\': \'/usr/lib/jvm/temurin-11-jdk-amd64\', \'CONDA_EXE\': \'/home/runner/miniconda-23.5.2/bin/conda\', \'_CE_M\': \'\', \'GITHUB_PATH\': \'/home/runner/work/_temp/_runner_file_commands/add_path_7d717e6f-e603-4689-915c-357b569257f3\', \'GITHUB_ACTION\': \'__run_5\', \'JAVA_HOME\': \'/usr/lib/jvm/temurin-11-jdk-amd64\', \'GITHUB_RUN_NUMBER\': \'1256\', \'RUNNER_NAME\': \'GitHub Actions 11\', \'GRADLE_HOME\': \'/usr/share/gradle-8.9\', \'GITHUB_REPOSITORY_OWNER_ID\': \'10713694\', \'ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE\': \'/opt/actionarchivecache\', \'XDG_CONFIG_HOME\': \'/home/runner/.config\', \'DOTNET_SKIP_FIRST_TIME_EXPERIENCE\': \'1\', \'ANT_HOME\': \'/usr/share/ant\', \'JAVA_HOME_8_X64\': \'/usr/lib/jvm/temurin-8-jdk-amd64\', \'GITHUB_TRIGGERING_ACTOR\': \'shankari\', \'GITHUB_REF_TYPE\': \'branch\', \'HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS\': \'3650\', \'ANDROID_NDK\': \'/usr/local/lib/android/sdk/ndk/27.0.12077973\', \'BOOTSTRAP_HASKELL_NONINTERACTIVE\': \'1\', \'PIPX_BIN_DIR\': \'/opt/pipx_bin\', \'PWD\': \'/home/runner/work/e-mission-server/e-mission-server\', \'STATS_TRP\': \'true\', \'CONDA_PREFIX\': \'/home/runner/miniconda-23.5.2/envs/emissiontest\', \'GOROOT_1_20_X64\': \'/opt/hostedtoolcache/go/1.20.14/x64\', \'DEPLOYMENT_BASEPATH\': \'/opt/runner\', \'GITHUB_REPOSITORY_ID\': \'26307245\', \'GITHUB_ACTIONS\': \'true\', \'STATS_VMD\': \'true\', \'ANDROID_NDK_LATEST_HOME\': \'/usr/local/lib/android/sdk/ndk/27.0.12077973\', \'SYSTEMD_EXEC_PID\': \'591\', \'GITHUB_SHA\': \'513dde391a53a77d8a2e7f594ab29f639d2269f4\', \'GITHUB_WORKFLOW_REF\': \'e-mission/e-mission-server/.github/workflows/test-with-manual-install.yml@refs/pull/961/merge\', \'POWERSHELL_DISTRIBUTION_CHANNEL\': \'GitHub-Actions-ubuntu22\', \'RUNNER_ENVIRONMENT\': \'github-hosted\', \'STATS_EXTP\': \'[https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.181+6/provjobd.data\](https://provjobdsettingscdn.blob.core.windows.net/settings/provjobdsettings-0.5.181+6/provjobd.data/)', \'DOTNET_MULTILEVEL_LOOKUP\': \'0\', \'GITHUB_REF\': \'refs/pull/961/merge\', \'RUNNER_OS\': \'Linux\', \'GITHUB_REF_PROTECTED\': \'false\', \'HOME\': \'/home/runner\', \'GITHUB_API_URL\': \'[https://api.github.com\](https://api.github.com/)', \'LANG\': \'C.UTF-8\', \'RUNNER_TRACKING_ID\': \'github_cc0140e6-1dc4-4a5e-b4bf-985c6b5650b6\', \'RUNNER_ARCH\': \'X64\', \'GOROOT_1_21_X64\': \'/opt/hostedtoolcache/go/1.21.12/x64\', \'RUNNER_TEMP\': \'/home/runner/work/_temp\', \'CONDA_PROMPT_MODIFIER\': \'(emissiontest) \', \'GITHUB_STATE\': \'/home/runner/work/_temp/_runner_file_commands/save_state_7d717e6f-e603-4689-915c-357b569257f3\', \'EDGEWEBDRIVER\': \'/usr/local/share/edge_driver\', \'JAVA_HOME_21_X64\': \'/usr/lib/jvm/temurin-21-jdk-amd64\', \'GITHUB_ENV\': \'/home/runner/work/_temp/_runner_file_commands/set_env_7d717e6f-e603-4689-915c-357b569257f3\', \'INVOCATION_ID\': \'091c2c6ff56b4618a77d0a3358ab3f44\', \'GITHUB_EVENT_PATH\': \'/home/runner/work/_temp/_github_workflow/event.json\', \'STATS_D\': \'true\', \'GITHUB_EVENT_NAME\': \'pull_request\', \'GITHUB_RUN_ID\': \'10356734071\', \'JAVA_HOME_17_X64\': \'/usr/lib/jvm/temurin-17-jdk-amd64\', \'ANDROID_NDK_HOME\': \'/usr/local/lib/android/sdk/ndk/27.0.12077973\', \'GITHUB_STEP_SUMMARY\': \'/home/runner/work/_temp/_runner_file_commands/step_summary_7d717e6f-e603-4689-915c-357b569257f3\', \'HOMEBREW_NO_AUTO_UPDATE\': \'1\', \'GITHUB_ACTOR\': \'shankari\', \'NVM_DIR\': \'/home/runner/.nvm\', \'SGX_AESM_ADDR\': \'1\', \'GITHUB_RUN_ATTEMPT\': \'1\', \'STATS_RDCL\': \'true\', \'ANDROID_HOME\': \'/usr/local/lib/android/sdk\', \'GITHUB_GRAPHQL_URL\': \'[https://api.github.com/graphql\](https://api.github.com/graphql/)', \'RUNNER_USER\': \'runner\', \'ACCEPT_EULA\': \'Y\', \'_CE_CONDA\': \'\', \'STATS_UE\': \'true\', \'USER\': \'runner\', \'GITHUB_SERVER_URL\': \'[https://github.com\](https://github.com/)', \'CONDA_SHLVL\': \'1\', \'STATS_V3PS\': \'true\', \'PIPX_HOME\': \'/opt/pipx\', \'GECKOWEBDRIVER\': \'/usr/local/share/gecko_driver\', \'STATS_EXT\': \'true\', \'CHROMEWEBDRIVER\': \'/usr/local/share/chromedriver-linux64\', \'SHLVL\': \'2\', \'NVM_CD_FLAGS\': \'\', \'ANDROID_SDK_ROOT\': \'/usr/local/lib/android/sdk\', \'VCPKG_INSTALLATION_ROOT\': \'/usr/local/share/vcpkg\', \'GITHUB_ACTOR_ID\': \'2423263\', \'RUNNER_TOOL_CACHE\': \'/opt/hostedtoolcache\', \'ImageVersion\': \'20240804.1.0\', \'DOTNET_NOLOGO\': \'1\', \'GITHUB_WORKFLOW_SHA\': \'513dde391a53a77d8a2e7f594ab29f639d2269f4\', \'GITHUB_REF_NAME\': \'961/merge\', \'CONDA_PYTHON_EXE\': \'/home/runner/miniconda-23.5.2/bin/python\', \'GITHUB_JOB\': \'build\', \'XDG_RUNTIME_DIR\': \'/run/user/1001\', \'AZURE_EXTENSION_DIR\': \'/opt/az/azcliextensions\', \'PERFLOG_LOCATION_SETTING\': \'RUNNER_PERFLOG\', \'CONDA_DEFAULT_ENV\': \'emissiontest\', \'STATS_VMFE\': \'true\', \'GITHUB_REPOSITORY\': \'e-mission/e-mission-server\', \'GOROOT_1_22_X64\': \'/opt/hostedtoolcache/go/1.22.5/x64\', \'ANDROID_NDK_ROOT\': \'/usr/local/lib/android/sdk/ndk/27.0.12077973\', \'CHROME_BIN\': \'/usr/bin/google-chrome\', \'GITHUB_RETENTION_DAYS\': \'90\', \'JOURNAL_STREAM\': \'8:20510\', \'RUNNER_WORKSPACE\': \'/home/runner/work/e-mission-server\', \'LEIN_HOME\': \'/usr/local/lib/lein\', \'XDG_DATA_DIRS\': \'/usr/local/share:/usr/share:/var/lib/snapd/desktop\', \'LEIN_JAR\': \'/usr/local/lib/lein/self-installs/leiningen-2.11.2-standalone.jar\', \'GITHUB_ACTION_REPOSITORY\': \'\', \'PATH\': \'/home/runner/miniconda-23.5.2/envs/emissiontest/bin:/home/runner/miniconda-23.5.2/condabin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/runner/.dotnet/tools\', \'RUNNER_PERFLOG\': \'/home/runner/perflog\', \'GITHUB_BASE_REF\': \'master\', \'GHCUP_INSTALL_BASE_PREFIX\': \'/usr/local\', \'CI\': \'true\', \'SWIFT_PATH\': \'/usr/share/swift/usr/bin\', \'ImageOS\': \'ubuntu22\', \'STATS_D_D\': \'true\', \'GITHUB_REPOSITORY_OWNER\': \'e-mission\', \'EXP_CONDA_VER_SUFFIX\': \'0\', \'GITHUB_HEAD_REF\': \'consolidate-differences\', \'GITHUB_ACTION_REF\': \'\', \'GITHUB_WORKFLOW\': \'ubuntu-only-test-with-manual-install\', \'DEBIAN_FRONTEND\': \'noninteractive\', \'GITHUB_OUTPUT\': \'/home/runner/work/_temp/_runner_file_commands/set_output_7d717e6f-e603-4689-915c-357b569257f3\', \'AGENT_TOOLSDIRECTORY\': \'/opt/hostedtoolcache\', \'_\': \'/home/runner/miniconda-23.5.2/envs/emissiontest/bin/python\', \'KMP_DUPLICATE_LIB_OK\': \'True\', \'KMP_INIT_AT_FORK\': \'FALSE\'}\nURL not formatted, defaulting to "Stage_database"\nConnecting to database URL localhost\nPlease provide the script with an argument. Use the "--help" option for more details\n

Old method of editing the string, for the record

        stripped_out_stdout = sp.stdout\
            .replace(b"\'CONDA_EXE\': \'/root/miniconda-23.5.2/bin/conda\', ",b"")\
            .replace(b"\'HOSTNAME\': \'78346225cfef\', ",b"")\
            .replace(b"\'EXP_CONDA_VER\': \'23.5.2\', ",b"")\
            .replace(b"\'CONDA_PREFIX\': \'/root/miniconda-23.5.2/envs/emissiontest\', ",b"")\
            .replace(b"\'CONDA_PYTHON_EXE\': \'/root/miniconda-23.5.2/bin/python\', ",b"")\
            .replace(b"\'PATH\': \'/root/miniconda-23.5.2/envs/emissiontest/bin:/root/miniconda-23.5.2/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\', ",b"")\
            .replace(b"\'_\': \'/root/miniconda-23.5.2/envs/emissiontest/bin/python\'",b"")

Consistent with
e-mission#961 (comment)

Testing done:

```
----------------------------------------------------------------------
Ran 21 tests in 23.106s

OK
```
@shankari
Copy link
Contributor

Squash-merging to avoid the multiple back-and-forth changes while polishing this.

  1. We don't really need to see the abandoned versions of the codebase in the history, particularly when they were clearly incorrect.
  2. The original code had a lot of duplicated copy-paste files which I have now fixed. Squash merging will ensure that the duplicate code never makes it into the codebase, particularly since it was only temporary.
  3. The actual change is fairly simple, so this will allow us to have a clean history that makes it easier to review later.

@shankari shankari merged commit f65f94c into e-mission:master Aug 12, 2024
5 checks passed
@shankari
Copy link
Contributor

The full set of environment variables supported can be determined by searching for the regular expression 'config.get("\[A-Z\]'
https://github.com/search?q=repo%3Ae-mission%2Fe-mission-server+%2Fconfig.get%5C%28%5C%22%5BA-Z%5D%2F&type=code

I have ensured that this is true now (b6f59b0) and we should make sure to ensure that it is true in the future as well.

@MukuFlash03 @nataliejschultz can you please update the docs accordingly?

@shankari
Copy link
Contributor

Cleanup issue e-mission/e-mission-docs#1082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants