Skip to content

Commit 34bc2db

Browse files
authored
Initial changes (#29)
1 parent 3839124 commit 34bc2db

File tree

13 files changed

+141
-108
lines changed

13 files changed

+141
-108
lines changed

protocol/innpv.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ message InitializeRequest {
5252
// compatability. If the protocol version is unsupported by the server, it
5353
// will respond with a ProtocolError.
5454
uint32 protocol_version = 1;
55+
56+
string project_root = 2;
57+
string entry_point = 3;
5558
}
5659

5760
message AnalysisRequest {

skyline/analysis/request_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def _handle_analysis_request(self, analysis_request, context):
5353
context.sequence_number,
5454
*(context.address),
5555
)
56+
connection = self._connection_manager.get_connection(context.address)
5657
analyzer = analyze_project(
57-
Config.project_root, Config.entry_point, self._nvml)
58+
connection.project_root, connection.entry_point, self._nvml)
5859

5960
# Abort early if the connection has been closed
6061
if not context.state.connected:

skyline/commands/interactive.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ def register_command(subparsers):
1616
"interactive",
1717
help="Start a new Skyline interactive profiling session.",
1818
)
19-
parser.add_argument(
20-
"entry_point",
21-
help="The entry point file in this project that contains the Skyline "
22-
"provider functions.",
23-
)
2419
parser.add_argument(
2520
"--host",
2621
default="",
@@ -93,8 +88,6 @@ def signal_handler(signal, frame):
9388
"Listening on port %d.",
9489
port,
9590
)
96-
logger.info("Project Root: %s", Config.project_root)
97-
logger.info("Entry Point: %s", Config.entry_point)
9891

9992
# Run the server until asked to terminate
10093
should_shutdown.wait()

skyline/commands/measurements.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ def actual_main(args):
7979
'samples_per_second',
8080
'memory_usage_bytes',
8181
])
82+
project_root = os.cwd()
8283
for batch_size in args.batch_sizes:
8384
for trial in range(args.trials):
8485
session = AnalysisSession.new_from(
85-
Config.project_root, Config.entry_point)
86+
project_root, args.entry_point)
8687
samples_per_second, memory_usage_bytes = make_measurements(
8788
session, batch_size)
8889
writer.writerow([

skyline/commands/memory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def actual_main(args):
4848
sys.exit(1)
4949

5050
try:
51+
project_root = os.cwd()
5152
session = AnalysisSession.new_from(
52-
Config.project_root, Config.entry_point)
53+
project_root, args.entry_point)
5354
session.generate_memory_usage_report(
5455
save_report_to=args.output,
5556
)

skyline/commands/prediction_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ def actual_main(args):
7575
'memory_usage_bytes_slope',
7676
'memory_usage_bytes_bias',
7777
])
78+
project_root = os.cwd()
7879
for batch_size in args.batch_sizes:
7980
session = AnalysisSession.new_from(
80-
Config.project_root, Config.entry_point)
81+
project_root, args.entry_point)
8182
memory_model, run_time_model = get_model(
8283
session, batch_size)
8384
writer.writerow([

skyline/commands/time.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def actual_main(args):
4949
sys.exit(1)
5050

5151
try:
52+
project_root = os.cwd()
5253
session = AnalysisSession.new_from(
53-
Config.project_root, Config.entry_point)
54+
project_root, args.entry_point)
5455
session.generate_run_time_breakdown_report(
5556
save_report_to=args.output,
5657
)

skyline/config/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ def __init__(self):
1010
self.warm_up = 100
1111
self.measure_for = 10
1212

13-
self.project_root = None
14-
self.entry_point = None
15-
1613
def initialize_hints_config(self, hints_file):
1714
if hints_file is None:
1815
file_to_open = skyline.data.get_absolute_path('hints.yml')
@@ -32,9 +29,5 @@ def parse_args(self, args):
3229
if 'measure_for' in args and args.measure_for is not None:
3330
self.measure_for = args.measure_for
3431

35-
def set_project_paths(self, project_root, entry_point):
36-
self.project_root = project_root
37-
self.entry_point = entry_point
38-
3932

4033
Config = _Config()

skyline/initialization.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,7 @@ def initialize_skyline(args):
2323
"""
2424
from skyline.config import Config
2525

26-
project_root = os.getcwd()
27-
entry_point = args.entry_point
28-
if not _validate_paths(project_root, entry_point):
29-
sys.exit(1)
30-
3126
Config.parse_args(args)
32-
Config.set_project_paths(project_root, entry_point)
33-
3427

3528
def _configure_logging(args):
3629
kwargs = {
@@ -76,34 +69,3 @@ def _validate_gpu():
7669
)
7770
return False
7871
return True
79-
80-
81-
def _validate_paths(project_root, entry_point):
82-
if not os.path.isabs(project_root):
83-
logger.error(
84-
"The project root that Skyline received is not an absolute path. "
85-
"This is an unexpected error. Please report a bug."
86-
)
87-
logger.error("Current project root: %s", project_root)
88-
return False
89-
90-
if os.path.isabs(entry_point):
91-
logger.error(
92-
"The entry point must be specified as a relative path to the "
93-
"current directory. Please double check that the entry point you "
94-
"are providing is a relative path.",
95-
)
96-
logger.error("Current entry point path: %s", entry_point)
97-
return False
98-
99-
full_path = os.path.join(project_root, entry_point)
100-
if not os.path.isfile(full_path):
101-
logger.error(
102-
"Either the specified entry point is not a file or its path was "
103-
"specified incorrectly. Please double check that it exists and "
104-
"that its path is correct.",
105-
)
106-
logger.error("Current absolute path to entry point: %s", full_path)
107-
return False
108-
109-
return True

skyline/io/connection.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def __init__(self, socket, address, handler_function, closed_handler):
2828
self._handler_function = handler_function
2929
self._closed_handler = closed_handler
3030
self._sentinel = Sentinel()
31+
self._project_root = ""
32+
self._entry_point = ""
3133

3234
def start(self):
3335
self._sentinel.start()
@@ -91,7 +93,18 @@ def _socket_read(self):
9193

9294
except:
9395
logger.exception("Connection unexpectedly stopping...")
94-
96+
97+
@property
98+
def project_root(self):
99+
return self._project_root
100+
101+
@property
102+
def entry_point(self):
103+
return self._entry_point
104+
105+
def set_project_paths(self, project_root, entry_point):
106+
self._project_root = project_root
107+
self._entry_point = entry_point
95108

96109
class ConnectionState:
97110
def __init__(self):

0 commit comments

Comments
 (0)