Skip to content

Commit

Permalink
revert irrelevant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendon-Hablutzel committed Nov 22, 2024
1 parent 3a778c2 commit c20ff94
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 42 deletions.
10 changes: 5 additions & 5 deletions extension/writing-process/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var RAW_DEBUG = false;
/* This variable must be manually updated to specify the server that
* the data will be sent to.
*/
var WEBSOCKET_SERVER_URL = "ws://localhost:80/wsapi/in?source=extension"
var WEBSOCKET_SERVER_URL = "wss://learning-observer.org/wsapi/in?source=extension"

import { googledocs_id_from_url } from './writing_common';

Expand All @@ -35,7 +35,7 @@ const loggers = [

loEvent.init('org.mitros.writing_analytics', '0.01', loggers, loEventDebug.LEVEL.SIMPLE);
loEvent.setFieldSet([loEventUtils.getBrowserInfo(), loEventUtils.fetchDebuggingIdentifier()]);
loEvent.go();
loEvent.go()

// Function to serve as replacement for
// chrome.extension.getBackgroundPage().console.log(event); because it is not allowed in V3
Expand Down Expand Up @@ -157,7 +157,7 @@ chrome.webRequest.onBeforeRequest.addListener(
'bundles': JSON.parse(formdata.bundles),
'rev': formdata.rev,
'timestamp': parseInt(request.timeStamp, 10)
};
}
logFromServiceWorker(event);
loEvent.logEvent('google_docs_save', event);
} catch(err) {
Expand All @@ -170,7 +170,7 @@ chrome.webRequest.onBeforeRequest.addListener(
'formdata': formdata,
'rev': formdata.rev,
'timestamp': parseInt(request.timeStamp, 10)
};
}
loEvent.logEvent('google_docs_save_extra', event);
}
} else if(this_a_google_docs_bind(request)) {
Expand All @@ -181,7 +181,7 @@ chrome.webRequest.onBeforeRequest.addListener(
},
{ urls: ["*://docs.google.com/*"] },
['requestBody']
);
)

// re-injected scripts when chrome extension is reloaded, upgraded or re-installed
// https://stackoverflow.com/questions/10994324/chrome-extension-content-script-re-injection-after-upgrade-or-install
Expand Down
4 changes: 2 additions & 2 deletions learning_observer/learning_observer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
# this to prefer the GPU where possible.
# spacy.prefer_gpu()
# debug_log("Preferring GPU Use.")
# spacy.require_gpu()
# debug_log("Requiring GPU Use.")
spacy.require_gpu()
debug_log("Requiring GPU Use.")


def configure_event_loop():
Expand Down
28 changes: 10 additions & 18 deletions learning_observer/learning_observer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
prog=__name__,
description="A system for monitoring",
epilog="For more information, see PMSS documentation.",
rulesets=[pmss.YAMLFileRuleset(
filename=learning_observer.paths.config_file())]
rulesets=[pmss.YAMLFileRuleset(filename=learning_observer.paths.config_file())]
)

# If we e.g. `import settings` and `import learning_observer.settings`, we
Expand All @@ -40,7 +39,6 @@
args = None
parser = None


def str_to_bool(arg):
if isinstance(arg, bool):
return arg
Expand Down Expand Up @@ -126,14 +124,13 @@ def parse_and_validate_arguments():
RUN_MODES = enum.Enum('RUN_MODES', 'DEV DEPLOY INTERACTIVE')
RUN_MODE = None

pmss.parser('run_mode', parent='string', choices=[
'dev', 'deploy', 'interactive'], transform=None)
pmss.parser('run_mode', parent='string', choices=['dev', 'deploy', 'interactive'], transform=None)
pmss.register_field(
name='run_mode',
type='run_mode',
description="Set which mode the server is running in.\n"
"`dev` for local development with full debugging\n"
"`deploy` for running on a server with better performance\n"
description="Set which mode the server is running in.\n"\
"`dev` for local development with full debugging\n"\
"`deploy` for running on a server with better performance\n"\
"`interactive` for processing data offline",
required=True
)
Expand Down Expand Up @@ -184,28 +181,24 @@ def load_settings(config):
elif settings_run_mode == 'interactive':
RUN_MODE = RUN_MODES.INTERACTIVE
else:
raise ValueError(
"Configuration setting for run_mode must be either 'dev', 'deploy', or 'interactive'")
raise ValueError("Configuration setting for run_mode must be either 'dev', 'deploy', or 'interactive'")

if 'repos' in settings:
for repo in settings['repos']:
# In the future, we might allow dicts if we e.g. want more metadata
if isinstance(settings['repos'][repo], str):
learning_observer.paths.register_repo(
repo, settings['repos'][repo])
learning_observer.paths.register_repo(repo, settings['repos'][repo])
elif isinstance(settings['repos'][repo], dict):
# HACK. We should figure out where to stick this. This does not belong in paths
debug_working = settings['repos'][repo].get(
"debug_working", None)
debug_working = settings['repos'][repo].get("debug_working", None)

learning_observer.paths.register_repo(
repo,
settings['repos'][repo]['path'],
debug_working=debug_working
)
else:
raise ValueError(
"settings.repos.{repo} should be a string or a dict. Please fix the settings file.".format(repo=repo))
raise ValueError("settings.repos.{repo} should be a string or a dict. Please fix the settings file.".format(repo=repo))

return settings

Expand Down Expand Up @@ -235,8 +228,7 @@ def initialized():


# Not all of these are guaranteed to work on every branch of the codebase.
AVAILABLE_FEATURE_FLAGS = ['uvloop', 'watchdog', 'auth_headers_page',
'merkle', 'save_google_ajax', 'use_google_ajax']
AVAILABLE_FEATURE_FLAGS = ['uvloop', 'watchdog', 'auth_headers_page', 'merkle', 'save_google_ajax', 'use_google_ajax']


def feature_flag(flag):
Expand Down
20 changes: 3 additions & 17 deletions learning_observer/util/stream_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import random
import sys
import time
import hashlib


ARGS = docopt.docopt(__doc__)
Expand Down Expand Up @@ -91,12 +90,10 @@ def argument_list(argument, default):
if isinstance(list_string, str):
list_string = [list_string] * STREAMS
if len(list_string) != STREAMS:
print(
f"Failure: {list_string}\nfrom {argument} should make {STREAMS} items")
print(f"Failure: {list_string}\nfrom {argument} should make {STREAMS} items")
sys.exit(-1)
return list_string


# TODO what is `source_files` supposed to be?
# when running this script for the workshop, we should either
# 1) move gpt3 texts out of writing observer (dependency hell) OR
Expand All @@ -106,11 +103,9 @@ def argument_list(argument, default):
if ARGS["--gpt3"] is not None:
import writing_observer.sample_essays
TEXT = writing_observer.sample_essays.GPT3_TEXTS[ARGS["--gpt3"]]
text_to_use = TEXT[0]
TEXT = [text_to_use for _ in range(STREAMS)]
STREAMS = len(TEXT)
elif source_files is None:
TEXT = ["\n".join(loremipsum.get_paragraphs(
int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)]
TEXT = ["\n".join(loremipsum.get_paragraphs(int(ARGS.get("--text-length", 5)))) for i in range(STREAMS)]
else:
TEXT = [open(filename).read() for filename in source_files]

Expand All @@ -129,7 +124,6 @@ def argument_list(argument, default):
None
)


if ARGS['--users'] is not None:
USERS = argument_list('--users', None)
elif ARGS['--fake-name']:
Expand All @@ -142,7 +136,6 @@ def argument_list(argument, default):
assert len(USERS) == STREAMS, "len(users) != STREAMS."
assert len(DOC_IDS) == STREAMS, "len(document IDs) != STREAMS."


def current_millis():
return round(time.time() * 1000)

Expand Down Expand Up @@ -185,13 +178,6 @@ def identify(user):
]


def str_to_hex(s: str) -> str:
s = s.encode()
sha256_hasher = hashlib.sha256()
sha256_hasher.update(s)
return sha256_hasher.hexdigest()


async def stream_document(text, ici, user, doc_id):
'''
Send a document to the server.
Expand Down

0 comments on commit c20ff94

Please sign in to comment.